I have a container div
with a few elements inside, like so:
<div class="container">
<p>one</p>
<p>two</p>
<p>three</p>
<p>four</p>
<p>five</p>
<p>six</p>
<p>seven</p>
<p>eight</p>
</div>
It looks like this:
You can the that the .container
div (in blue) extends to fill the whole width of the window. I would like it to always 'hug' the p
's inside, to always have the minimum width
necessary.
I have accomplished by setting it to display: inline-block
. Now it looks like
Here comes the problem. When I re-size the window so that one of the elements gets 'pushed' down to a second row, the .container
div does not shrink to fit the new size of the elements. Instead, it stretches to the edge of the window.
How would I make the div fit its contents, even when re-sizing, so that it would look like so?
I have searched and searched, but could not find an answer to this problem.
JSFiddle Here