Generate CSS tooltip styles
Position
Content
Styling
Animation
Preview (Hover to see tooltip)
CSS
.tooltip-trigger {
position: relative;
cursor: pointer;
}
.tooltip-content {
position: absolute;
bottom: 100%;
left: 50%;
margin-bottom: 14px;
background-color: #1f2937;
color: #ffffff;
font-size: 14px;
padding: 8px 12px;
border-radius: 6px;
max-width: 200px;
white-space: nowrap;
z-index: 10;
opacity: 0;
visibility: hidden;
transition: opacity 200ms ease, visibility 200ms ease;
}
.tooltip-trigger:hover .tooltip-content {
opacity: 1;
visibility: visible;
}
.tooltip-content::before {
content: '';
position: absolute;
top: 100%;
left: 50%; margin-left: -6px;
border-width: 6px;
border-style: solid;
border-color: #1f2937 transparent transparent transparent;
}HTML
<span class="tooltip-trigger"> Hover me <span class="tooltip-content">This is a tooltip</span> </span>