Skip to content

Instantly share code, notes, and snippets.

@maxhoffmann
Created February 27, 2013 14:10
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 maxhoffmann/5048150 to your computer and use it in GitHub Desktop.
Save maxhoffmann/5048150 to your computer and use it in GitHub Desktop.
CSS only tooltip
/**
* CSS only tooltip
*/
.tooltip:hover {
position: relative;
}
.tooltip:before,
.tooltip:after {
opacity: 0;
position: absolute;
pointer-events: none;
}
.tooltip:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
content: attr(title);
padding: 6px 8px;
bottom: calc(100% + 8px);
left: 0;
min-width: 100%;
background-color: rgba(0,0,0,.7);
color: white;
font-size: 14px;
border-radius: 4px;
text-align: center;
-webkit-font-smoothing: antialiased;
}
.tooltip:before {
content: "";
left: 50%;
bottom: calc(100% - 4px);
margin-left: -6px;
width: 0;
height: 0;
border-color: transparent;
border-width: 6px;
border-style: solid;
border-top-color: rgba(0,0,0,.7);
}
.tooltip:hover:after,
.tooltip:hover:before {
opacity: 1;
-webkit-transition: opacity .5s ease;
transition: opacity .5s ease;
}
html {
font-family: sans-serif;
}
<br><br><br>
<a href="#" title="tasad" class="tooltip">132215</a>
// alert('Hello world!');
{"view":"separate","fontsize":"100","seethrough":"","prefixfree":"1","page":"all"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment