The base
<a href="#" data-title="Some tooltip">Some link</a>
[data-title] {
display: inline-block;
position: relative;
}
[data-title]:before,
[data-title]:after {
background: #eee;
bottom: 100%;
content: '';
opacity: 0;
pointer-events: none;
position: absolute;
z-index: 10;
}
[data-title]:before {
color: #222;
content: attr(data-title);
margin-bottom: 6px;
padding: .5em 1em;
white-space: nowrap;
}
[data-title]:after {
height: 13px;
left: 50%;
margin-left: -6px;
transform: rotateZ(45deg);
width: 13px;
}
[data-title]:hover:before,
[data-title]:hover:after {
opacity: 1;
}
Position
At the bottom
<a href="#" data-title="Some tooltip" data-title-position="bottom">Some link</a>
[data-title][data-title-position="bottom"]:before {
bottom: auto;
margin-top: .5rem;
top: 100%;
}
[data-title][data-title-position="bottom"]:after {
bottom: auto;
top: 100%;
}
On the right
<a href="#" data-title="Some tooltip" data-title-position="right">Some link</a>
[data-title][data-title-position="right"]:before {
bottom: auto;
left: 100%;
margin-left: .95rem;
top: -15%;
}
[data-title][data-title-position="right"]:after {
bottom: auto;
left: 100%;
margin-left: .5rem;
margin-top: -.5rem;
top: 50%;
}
Custom look
Rounded corners
<a href="#" data-title="Some tooltip" class="tooltip-rounded">Some link</a>
.tooltip-rounded[data-title]:before {
border-radius: 6px;
}
Border
<a href="#" data-title="Some tooltip" class="tooltip-bordered">Some link</a>
.tooltip-bordered[data-title]:before,
.tooltip-bordered[data-title]:after {
border: 1px solid #ddd;
}
.tooltip-bordered[data-title]:after {
border-width: 0 1px 1px 0;
}
.tooltip-bordered[data-title][data-title-position="bottom"]:after {
border-width: 1px 0 0 1px;
}
.tooltip-bordered[data-title][data-title-position="right"]:after {
border-width: 0 0 1px 1px;
}
Dark
<a href="#" data-title="Some tooltip" class="tooltip-dark">Some link</a>
.tooltip-dark[data-title]:before,
.tooltip-dark[data-title]:after {
background: #222;
color: #eee;
}
Success
<a href="#" data-title="Some tooltip" class="tooltip-success">Some link</a>
.tooltip-success[data-title]:before,
.tooltip-success[data-title]:after {
background: #4db135;
color: #eee;
}
Error
<a href="#" data-title="Some tooltip" class="tooltip-error">Some link</a>
.tooltip-error[data-title]:before,
.tooltip-error[data-title]:after {
background: #e13c38;
color: #eee;
}
Classic
<a href="#" data-title="Some tooltip" class="tooltip-classic">Some link</a>
.tooltip-classic[data-title]:before,
.tooltip-classic[data-title]:after {
background: #ffffa9;
border: 1px solid #ddd;
}
.tooltip-classic[data-title]:before {
border-radius: 6px;
}
.tooltip-classic[data-title]:after {
border-width: 0 1px 1px 0;
}
.tooltip-classic[data-title][data-title-position="bottom"]:after {
border-width: 1px 0 0 1px;
}
.tooltip-classic[data-title][data-title-position="right"]:after {
border-width: 0 0 1px 1px;
}