I have nested divs like so:
<div class="first">
<div class="second">
<div class="third"></div>
</div>
</div>
The third div contains dynamic content – so I don’t know it’s dimensions.
What I want is the second div to take the width of the third div and not of the first div which is a lot bigger.
So in this demo, I want the border to enclose the green square.
Is this possible with css only? if so, how?
Thanks.
Put a
float: left;in the second class. That should do the trick.