Skip to content

Instantly share code, notes, and snippets.

@barnettjw
Created April 10, 2015 12:34
Show Gist options
  • Save barnettjw/2c1612c20e4669d1b8d3 to your computer and use it in GitHub Desktop.
Save barnettjw/2c1612c20e4669d1b8d3 to your computer and use it in GitHub Desktop.
Simple CSS Tooltips
<div class = "tooltip-container">
<p class = "tooltip-content">Hover for tooltip</p>
<span class = "tooltip-tip">I'm a tooltip</span>
</div>
/* basic styling */
body { margin: 30px; }
.tooltip-content {
font-size: 1.5em;
font-weight: bold;
}
/* tooltips */
.tooltip-container { position: relative; }
.tooltip-tip { display: none; }
.tooltip-content:hover + .tooltip-tip {
display: inline-block;
position: absolute;
top: 0;
left: 260px;
min-width: 100px;
padding: 5px 20px;
text-align: center;
background-color: #ddd;
opacity: .9;
border: 1px solid #ddd;
border-radius: 4px;
background-image: linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,0));
box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 1px 0 rgba(255,255,255,.5) inset;
}
/* little triangle on the tooltip */
.tooltip-tip:before {
content: "";
position: absolute;
width: 0;
height: 0;
top: 7px;
left: -9px;
border-top: 9px solid transparent;
border-bottom: 9px solid transparent;
border-right: 9px solid #ddd;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment