Creating Simple tooltip using CSS
tooltip — очень просто и качественно, чистый CSS
by akogch
HTML
<h1>
Tooltip demo using CSS
</h1>
<ul>
<li>The tooltip will appear on
<span class="tooltip">Top
<span class="tooltiptext tooltip-top">I never lose. Either I win or I learn.</span>
</span>
</li>
<li> The tooltip will appear on
<span class="tooltip">Left
<span class="tooltiptext tooltip-left">He said "I'll always be here". Then he left.</span>
</span>
</li>
<li>The tooltip will appear on
<span class="tooltip">Right
<span class="tooltiptext tooltip-right">Do what is right, not what is easy.</span>
</span>
</li>
<li>The tooltip will appear on
<span class="tooltip">Bottom
<span class="tooltiptext tooltip-bottom">Bottom line is, everyone thinks differently.</span>
</span>
</li>
</ul>
CSS
body {
font-family: Calibri;
}
ul {
margin-top: 20px;
}
li {
line-height: 30px;
}
.tooltip {
position: relative;
display: inline-block;
border-bottom: 1px dotted grey;
color: #005050;
}
.tooltip .tooltiptext {
visibility: hidden;
position: absolute;
width: 180px;
background-color: #555;
color: #fff;
text-align: center;
padding: 2px;
border-radius: 5px;
z-index: 1;
opacity: 0;
transition: opacity .6s;
}
.tooltip:hover .tooltiptext {
visibility: visible;
opacity: 1;
}
.tooltip-top {
bottom: 90%;
margin-left: -60px;
}
.tooltip-left {
top: -5px;
right: 128%;
}
.tooltip-bottom {
top: 100% margin-left: -60px;
}
.tooltip-right {
top: -5px;
left: 125%;
}