I have a container div and two nested divs within. I do not have control over the content of either of these nested divs.
What I essentially need is to make the two nested divs always have the same height. I figured this can be achieved by giving the container div height:auto so that it would stretch its own height to the tallest of the two nested divs (each of which stretches to fit its own content), and then the other nested div would stretch to 100% of the container's height.
Here's what I tried:
Style:
#container{
background-color:#FF0;
overflow:auto;
}
#left{
float:left;
height:100%;
width:20%;
background-color:#F00;
}
#right{
height:100%;
width:60%;
background-color:#0F3;
}
HTML:
<div id="container">
<div id="left">
<p>Content</p>
<p>Content</p>
<p>Content</p>
</div>
<div id="right">
<p>Content</p>
<p>Content</p>
</div>
</div>
But this does not work. The container stretches to fit the longest div ("left" in this case) but the shorter nested div ("right") does not stretch itself.
Note, however, that this DOES work if I give the container a specific height:
#container{
background-color:#FF0;
overflow:auto;
height:300px;
}
Is there any way I can get this to work without resorting to tables? Your help is much appreciated.