Created
June 17, 2015 11:21
-
-
Save benjamincharity/209360d7a6e5ce41fef0 to your computer and use it in GitHub Desktop.
CSS tooltip.
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
@mixin tooltip( | |
$content: attr(data-tooltip), | |
$direction: top | |
) { | |
position: relative; | |
&:before, &:after { | |
display: none; | |
z-index: 98; | |
} | |
&:hover { | |
&:after { // for text bubble | |
content: $content; | |
display: block; | |
position: absolute; | |
height: 12px; // (makes total height including padding 22px) | |
padding: 6px; | |
font-size: 12px; | |
white-space: nowrap; | |
color: #fff; | |
@include text-shadow(1px 1px #000); | |
background-color: #222; | |
} | |
@if ($direction == 'top'){ | |
&:before { | |
@include triangle(down, 6px, #222); | |
top: -6px; margin-top: 0; | |
left: 47%; | |
} | |
&:after { | |
top: -28px; | |
left: 47%; margin-left: -20px; | |
} | |
} | |
@else if ($direction == 'bottom'){ | |
&:before { | |
@include triangle(up, 6px, #222); | |
top: auto; margin-top: 0; | |
bottom: -6px; | |
left: 47%; | |
} | |
&:after { | |
bottom: -28px; | |
left: 47%; margin-left: -20px; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment