Skip to content

Instantly share code, notes, and snippets.

@BryanMoslo
Created July 16, 2018 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BryanMoslo/808f7acb1dafcd049a1aebbeef8c2755 to your computer and use it in GitHub Desktop.
Save BryanMoslo/808f7acb1dafcd049a1aebbeef8c2755 to your computer and use it in GitHub Desktop.
CSS Tooltip
<button class="tooltip" tooltip-title="Save">Hover over me</button>
body{
padding: 50px;
}
.tooltip {
position: relative;
}
.tooltip:before {
content: attr(tooltip-title);
min-width: 54px;
background-color: #999999;
color: #fff;
font-size: 12px;
border-radius: 4px;
padding: 9px 0;
position: absolute;
top: -42px;
left: 50%;
margin-left: -27px;
visibility: hidden;
opacity: 0;
transition: opacity 0.3s;
}
.tooltip:after {
content: "";
position: absolute;
top: -9px;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #999999 transparent transparent;
visibility: hidden;
opacity: 0;
transition: opacity 0.3s;
}
.tooltip:hover:before,
.tooltip:hover:after{
visibility: visible;
opacity: 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment