This is how my code may go:-
<div id="parent" style="width:49%">
<div id="left" style="float:left;clear:both;width:auto">BLAH!BLAH!Content goes here</div>
<div id="right" style="float:left;clear:both:width:250px">Content again goes here!</div>
</div>
So basically I want left to auto-size based on the the width of “right” but must stay in limits of the “parent” container!
I looked up many places but didn’t find sensible answers! Hope this website can help me! 😀
Thanks in advance
Float
#rightto the right, and do not float#leftbut give it amargin-rightwhich is equal to the width of#right. If you float#left, it will take up the size of its contents, but if you don’t float it, it will take up the possible maximum width it can. And you just lower this maximum width by setting a margin.Demo
Notice that in the markup I changed the order of divs:
And the important part of the CSS:
Tested in FF4, Chrome, IE8.