Last active
August 29, 2015 14:04
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*[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