css animated tooltip
by polaszk
HTML
<span title="title">text</span>
<span data-info="tooltip">text</span>
CSS
span {
display: inline-block;
margin: 30px 20px 20px;
position: relative;
}
[data-info] {
position: relative;
}
[data-info]:after {
font-family: 'Source Sans Pro', sans-serif;
display: none;
opacity: 0;
text-align: center;
padding: 5px 10px;
border-radius: 1px;
box-shadow: 1px 1px 2px 0 rgba(0, 0, 0, .4);
bottom: calc(100% + 3px);
left: 50%;
white-space: nowrap;
background-color: #525252;
border: 1px solid #4a4a4a;
color: #fff;
text-transform: none;
font-size: 15px;
line-height: 1;
position: absolute;
}
[data-info]:hover::after {
content: attr(data-info);
display: block;
opacity: 1;
z-index: 99;
transform: translate(-50%, -.5em);
animation: tooltips 200ms ease-out forwards;
}
[data-info='']::before,
[data-info='']::after {
display: none!important;
}
@-webkit-keyframes tooltips {
to {
-webkit-transform: translate(-50%, 0);
transform: translate(-50%, 0);
}
}
@keyframes tooltips {
to {
transform: translate(-50%, 0);
}
}