Super Simple Animated Html5 & CSS3 Tooltip

Category: CSS & CSS3 , tooltip | July 20, 2014
Author: designcouch
Views Total: 4,010
Official Page: Go to website
Last Update: July 20, 2014
License: MIT

Preview:

Super Simple Animated Html5 & CSS3 Tooltip

Description:

A simple CSS3 animated tooltip that displays content from Html5 data-description attribute of any Html elements.

How to use it:

Create an Html element with an unique ID ‘tooltip’ and use data-description attribute to declare the tooltip content.

<div id="tooltip" data-description="I'm a tooltip">
  I have a tooltip.
</div>

The required CSS to style & animate the tooltip.

#tooltip {
  width: 350px;
  font-family: Helvetica, Arial, sans-serif;
  font-weight: 100;
  font-size: 20px;
  text-align: center;
  padding: 50px;
  margin: 100px auto;
  background: white;
  position: relative;
  border-radius: 5px;
  box-shadow: 10px 10px 0px rgba(0,0,0,.05);
}

#tooltip:before {
  content: attr(data-description);
  box-sizing: border-box;
  display: block;
  background: rgba(0,0,0,.7);
  color: white;
  padding: 20px;
  position: absolute;
  left: 50%;
  top: -30px;
  margin-left: -100px;
  width: 200px;
  height: 65px;
  line-height: 25px;
  border-radius: 5px;
  opacity: 0;
  transition: .25s ease-in-out;
}

#tooltip:after {
  content: '';
  display: block;
  position: absolute;
  top: 35px;
  left: 50%;
  margin-left: -8px;
  height: 0;
  width: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid rgba(0,0,0,.7);
  transition: .25s ease-in-out;
  opacity: 0;
}

#tooltip:hover:before {
  opacity: 1;
  top: -50px;
}

#tooltip:hover:after {
  opacity: 1;
  top: 15px;
}

You Might Be Interested In:


Leave a Reply