Let's say I have 2 divs within a wrapper side by side.
<div id="wrapper">
<div id="primary"></div>
<div id="secondary"></div>
</div>
#primary {
width:50%;
float: left;
}
#secondary {
width: 50%;
}
How can I make sure div secondary always has the same height as div primary
There's a pretty cool trick on how to do this.
jsFiddle Demo
First, you apply
padding-bottom: 100%;
to each side-by-side div.Next, you apply
margin-bottom: -100%;
to each side-by-side div. Note the-
Finally, you add
overflow:hidden;
to the div they are inside.Presto! True happiness is yours.
HTML:
CSS:
References:
http://www.ejeliot.com/blog/61