Supports IE8+
A Pen by James Barnett on CodePen.
<div class = "tooltip-container"> | |
<p class = "tooltip-content">Hover for tooltip</p> | |
<span class = "tooltip-tip">I'm a tooltip</span> | |
</div> |
Supports IE8+
A Pen by James Barnett on CodePen.
/* 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; | |
} |