Created
May 28, 2015 00:22
-
-
Save ile/e28c8b76366c5b475545 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* Add this attribute to the element that needs a tooltip */ | |
[data-tool] | |
position relative | |
z-index 2 | |
cursor pointer | |
/* Hide the tooltip content by default */ | |
[data-tool]:before, | |
[data-tool]:after | |
opacity 0 | |
display none | |
pointer-events none | |
/* Position tooltip above the element */ | |
[data-tool]:before | |
position absolute | |
top 100% | |
left 50% | |
margin-left -80px | |
padding 7px | |
width 160px | |
border-radius 4px | |
background-color hsla(0, 0%, 20%, 0.9) | |
color #fff | |
content attr(data-tool) | |
text-align center | |
font-size 14px | |
line-height 1.2 | |
margin-top 12px | |
text-transform none | |
/* Triangle hack to make tooltip look like a speech bubble */ | |
[data-tool]:after | |
position absolute | |
top 100% | |
left 50% | |
margin-left -5px | |
width 0 | |
border 6px solid transparent | |
border-top-color transparent | |
border-bottom-color hsla(0, 0%, 20%, 0.9) | |
content " " | |
font-size 0 | |
line-height 0 | |
/* Show tooltip content on hover */ | |
[data-tool]:hover:before, | |
[data-tool]:hover:after | |
display block | |
opacity 1 | |
animation 0.9s appear-down-2 cubic-bezier(0, 1, 0, 1) | |
Author
ile
commented
May 28, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment