Skip to content

Instantly share code, notes, and snippets.

@grtner
Created May 3, 2012 12:06
Show Gist options
  • Save grtner/2585238 to your computer and use it in GitHub Desktop.
Save grtner/2585238 to your computer and use it in GitHub Desktop.
Tooltip with CSS3
/**
* Tooltip with CSS3
*/
html {
background-color: #b2bec2;
background-image: linear-gradient(top, rgb(225, 229, 222), rgb(131, 151, 166));
min-height: 100%; }
body { width: 500px; margin: 100px auto; color: white; font-size: 1em; line-height: 1.5; font-family: "Helvetica";}
p {text-shadow: 0 1px 1px rgba(0,0,0,.1); margin-bottom: 1.5em;}
[data-tooltip] {
font-weight: 600;
color: #f9f3ec;
position: relative;
cursor: pointer;
}
[data-tooltip]:after {
content: attr(data-tooltip);
font-size: .875em;
color: white;
white-space:nowrap;
position: absolute;
bottom: 110%;
left:.5em;
display: none;
opacity: 0;
padding: .5em .75em;
border: 1px solid rgba(0,0,0,.9);
border-radius: 2px;
background-color: rgba(0,0,0,.7);
box-shadow: 1px 2px 3px rgba(0,0,0,.2),
inset 0px 1px 2px rgba(255,255,255,.3);
pointer-events: none;
}
[data-tooltip]:hover:after {
display: block;
opacity: 1;
}
<!-- content to be placed inside <body>…</body> -->
<p>Mumblecore vinyl marfa chillwave cosby sweater tumblr. Authentic blog wolf, fap vinyl tumblr pickled hella put a bird on it. Lomo retro DIY, laboris chillwave iphone biodiesel cred. </p>
<p>Ad <span data-tooltip="Sample description">chambray</span> you probably haven't heard of them brunch messenger bag, odd future quis pickled duis viral aliquip esse do keytar. Laborum ennui nihil 3 wolf moon mixtape flexitarian tofu, dreamcatcher high life aliqua stumptown sint selvage. Veniam leggings occaecat street art occupy, seitan magna reprehenderit mcsweeney's fap. Assumenda sunt retro echo park, quis qui helvetica vinyl laborum odio vero artisan ea butcher.</p>
{"view":"split-vertical","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