I have a css tooltip attached to a span as follows:
<span class="mytooltip" data-mytooltip="Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. ">
Has Tooltip
</span>
The CSS is in short:
.mytooltip {
display: inline-block;
position: relative;
}
.mytooltip:hover:after {
content: attr(data-mytooltip);
display: block;
margin-top: 0.7rem;
margin-left: -1rem;
left: auto;
bottom: auto;
padding: .3rem 1rem;
position: absolute;
z-index: 98;
width: 400px;
}
In .mytooltip:hover:after{}
width: 400px
and
max-width: 400px; white-space: nowrap;
works as expected. The later doesn't make much sense, because though the pseudo element has the right width, the text is floating over, when it's longer than 400px.
Is there a way to use max-width on the pseudo element with the text wrapped inside?
I'd be very grateful for advice.