I have this html:
<div class="container">
<span>
The lime outlined .container had two vertically stacked elements, this text (which is inline) and the salmon .fixed-width box which is block and has an explicit width and height set externally. I want .container to shrink to the size of .fixed-width and the inline content to wrap. I do not want to have to set an explicit width on .container.
</span>
<div>
<div class="fixed-width"></div>
</div>
</div>
and this css
.fixed-width {
background-color: salmon;
height: 200px;
width: 200px;
}
/*for debugging*/
.container { outline: 1px solid lime; }
.container * { outline: 1px solid blue; }
What I would like is for .container
to be the same size as .fixed-width
without explicitly setting it anywhere else, thereby making the inline text wrap and be no larger than 200px in width.
I'm pretty sure this isn't possible with css2 but my browser requirements are pretty modern (I'm using flexbox on the same page) so I'm hoping there's a way to do it with css3.
I'm open to introducing some new markup here if need be.