I have run into this problem:
span {
width: fit-content;
background-color: yellow;
}
div {
width: fit-content;
border: black 1px solid;
max-width: 100px;
}
<div>
<span>Fooooo Barrrrrrrr</span>
</div>
<p>The right side border should be touching the right side of the longest line.</p>
I would like the div to be as close to the size of the span as possible. I have put width: fit-content;
there but it seems to only fit to its own max-width
. I am not asking to fit the div to the boundries of every line, but it should be as wide as the widest line in span
. How can I resolve this?