I have two divs whose widths are controlled by percentages. I want the right div to be exactly as tall as the left div, which expands and shrinks based on the width of the image it contains and the width of the browser window.
Is there a way to accomplish this without javascript?
The simplest way to achieve this is to make the
.rightdiv absolutely positioned and settingtopandbottomto0.Just remember to position the parent (
.main) div relatively and remove all of the floats:Working example: http://jsfiddle.net/5JU2t/1/
Note
The reason the right column is a little longer in the example is due to the white space added under an image. Should you only be using an image in this column then you can add
float: leftto the image to resolve this:Working example: http://jsfiddle.net/5JU2t/2/