<div id='container'>
<div class='left'></div>
<div class='right'></div>
<div class='clear'></div>
</div>
Given the simple markup above, which can be seen in action here at jsFiddle, how do you get the floated right div to take up the remaining height of its parent container that doesn’t have an explicit height? The parent container’s final height is determined by the floated left div.
Typically, I solve this issue through Javascript, and fix the heights after the page has loaded. But, there must be an alternative, standard, and optimal method of how this is handled.
I think this is just an inherent issue of structuring a layout this way, so what is the alternative beyond using a <table>?
Can’t be done without explicit height on the parent using floats.
You can however use
display: table-;andtable-cellwhich mimics the behavior of tables without actually using them:This way you don’t need the clearing element and the two divs will always take up 100% of the height, as long as it’s declared.
http://jsfiddle.net/6XagR/4/