I'm tackling the challenge of crafting a basic tooltip without relying on JavaScript.
I'm pondering the most effective approach to achieve this. I aim to have the tooltip container accommodate dynamic text seamlessly, adjusting responsively atop its container. The current issue lies in the fact that the text does not naturally expand, causing words to break into new lines, altering the overall height and resulting in misaligned positioning and container overlap.
table {
margin-top: 100px;
}
td {
border: solid 1px #000;
height: 25px;
width: 25px;
position: relative;
}
div {
position: absolute;
top: -25px;;
}
span {
display: inline-block;
border-radius: 5px;
background: #000;
color: #fff;
position: absolute;
font-size: 15px;
padding: 5px;
width: auto;
}
td:hover div span {
display: inline-block;
}
<table>
<tr>
<td>
something
<div>
<span>
text
</span>
</div>
</td>
<td>
something
<div>
<span>
some long text
</span>
</div>
</td>
</tr>
</table>