Fancy pure CSS3 hover tooltips with animations

This tutorial covers how to create really basic tooltips that can be used anywhere and for anything. The tooltips are completely CSS based and only animations are CSS3 otherwise they will work on any platform.

 

What They Look Like:

See the Pen KdveeO by Alex (@fabriceleven) on CodePen.

 

How it Works:

  • We first create a unique div class that we will attach to div classes where we want the tooltip to show up.
  • Inside this div class, we will then create a span class that will house our tooltip.
  • When users hover over the area to which the “tooltip” class is attached, our span class will become visible again, thus creating a tooltip.
  • We also add some styling—like adding the pointing notch and CSS3 animation—to make things fancier.

Let’s Get Started—the HTML

First a little mark-up to create the staging area.

 

 

  • We have attached the “tooltip” tag to the bold class which surrounds “hover over me here” this will trigger the tooltip to show up once we hover over that area.
  • The span under it is the actual tooltip and you can put whatever html you want in there. It will only become visible once you hover over it.

The CSS to Make it all Work

In the “.tooltip:hover span {“ we turn on our tooltip and give it a position where it should show up relative to the tooltip container. You can adjust left and top to get it in just the right place.

In the “.tooltip span {“ class we style our tooltip and give it initial position, then hide it. Based on the Left and Top values here our tooltip will either slide from the bottom or from another place. You can style this however you want—you can add rounded corners, texture etc.

In the “.tooltip span:after {“ we add the little arrow pointing down. Essentially we create a border radius with a high value and then give it an absolute position.

That’s it!