I have two divs (DivLeft, DivRight) next to each other, they are wrapped in DivHolder. DivRight contains another divs and thus expand in height. I want the DivLeft to have min-height same as DivRight has.
HTML looks more or less like this:
<div class="DivHolder">
<div class="DivLeft"></div>
<div class="DivRight">
<div class="add1"></div>
<div class="add2"><img ...></div>
<div class="add3"><img ...></div>
....
</div>
</div>
Tried this script
$(document).ready(function () {
if ($(".DivHolder").length > 0) {
$(".DivLeft").css("minHeight", $(".DivRight").height());
}
}
and it append some height to DivLeft, but a wrong one. I checked the height of DivRight, and it is 720px, but the min-height DivLeft gain is 241px. No div that is contained in DivRight is of this height. It seems to be a "random" value. Anyone see the problem?
Thanks!
EDIT: I have found the root of the problem is that some of the divs that are included in DivRight contains images. These images are not loaded when I call my function and thus DivRight appears to be shorter.
I changed $(document).ready(function () for $(window).load(function() {, but now I can see the DivLeft jumps in height (at first its original height is set and after the images are loaded, it extends). That looks bad. Any tips how to improve it?