I understand that display: inline-block
will cause a parent element to "shrink" to the width of the largest child element. This is exactly what I want if the largest element is an element like <img />
.
However, if a line of text happens to be really long, it expands the width of the parent.
<div class="hi">
<img src="http://placehold.it/350x150" />
<div class="longtext">
Eu duis eram anim senserit. Quae deserunt voluptatibus ex noster nam eu sunt laboris ea consequat ut amet litteris, ingeniis hic sint, et elit voluptatibus te legam do possumus, fugiat sempiternum tempor irure laboris, possumus tamen sunt expetendis quid.
</div>
<div class="short">wow</div>
</div>
Fiddle so you can see the problem.
How can I force a really long line of text to take the width of the parent, which is in turn taking the width from a child element?
The closest I can get to what I want is position: absolute
but it takes the text out of the block-level (pushing everything up).