Skip to content

Instantly share code, notes, and snippets.

@aprice
Last active August 29, 2015 14:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aprice/cc11f55bfc5f007365ba to your computer and use it in GitHub Desktop.
Save aprice/cc11f55bfc5f007365ba to your computer and use it in GitHub Desktop.
HTML5/CSS3 tooltips. Any visible element with a data-tooltip attribute will have the value of that attribute displayed in a tooltip on hover, using only CSS.
*[data-tooltip]::before
{
box-shadow: .3em .3em .3em rgba(0, 0, 0, 0.4);
max-width: 30em;
font-size: 80%;
font-weight: normal;
background: #ff9;
color:#000;
border: 1pt solid #000;
padding: 0.5em;
margin: -2em 0 0 2em;
text-align: left;
height: auto;
display: block;
position: absolute;
z-index: 9999;
opacity: 0;
top: -9999px;
-moz-transition: opacity 0.4s ease-out;
-o-transition: opacity 0.4s ease-out;
-webkit-transition: opacity 0.4s ease-out;
transition:opacity 0.4s ease-out;
content: attr(data-tooltip);
}
*[data-tooltip]:hover::before
{
opacity: 1;
top: auto;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment