I have been exploring ways to incorporate multiple tooltips into text on my website. After experimenting with both span and div tags, I was able to create a tooltip using CSS only. However, I am facing challenges with positioning the tooltiptext correctly. Currently, it appears below and to the left of the hoverable word instead of directly above it as intended. Here is the snippet of my code:
.tooltip {
position: relative;
display: inline;
text-decoration: underline dotted black;
}
.tooltip:hover .tooltiptext {
display: block;
position: absolute;
z-index: 3;
padding: 0.3vw;
}
.tooltiptext {
display: none;
color: white;
background-color: black;
border-radius: 0.3vw;
}
<p>Lorem ipsum dolor sit amet,
<span class="tooltip"> consectetuer<span class="tooltiptext"> Some Text</span></span>
adipiscing elit. Aenean commodo ligula eget dolor.</p>
Does anyone have suggestions for resolving this issue?