views:

89

answers:

1

Hey, I was working on a solution to my equal height three columns CSS equal height layout with jQuery, because the CSS workarounds were really giving me some trouble.

I came up with the following code:

$('.columns').css("height", "$('#detail').height()");

But for some reason, I don't see any effect when I reload my web page.

I even tried waiting nesting it in a (window).load() event handler instead of the (document).ready() just to test it out.

I was wondering if it's not possible to set the CSS property of an element as a jQuery statement or something like that.

Or, is it because my height for my <div id="#detail> is not set at all.

I also tried setting #detail to height: auto; but this did not work either.

Please tell me if this is an impossible workaround I'm trying to find here, but hopefully why! :)

+1  A: 

Set overflow: hidden; on your #detail div. Also, jQuery's .height() returns a number. CSS requires us to put px at the end. This should work for you.

$('.columns').css('height', $('#detail').height() + 'px');
Brian Ray
Hmm, let me work it out here, but it seems to be throwing it off, because of the placement. Although it looks as though this problem has been fixed.
BOSS
You could try replacing the overflow: hidden with a clear div after the last floated element in the #detail div.
Brian Ray
What do you mean by this?
BOSS
Remove the overflow: hidden style from the detail id. Instead, do this.style: .clear { height: 0px; margin: 0px; padding: 0px; clear: both; }code:<div id="details"> <div class="columns">column1 content</div> <div class="columns">column2 content</div> <div class="columns">column3 content</div> <div class="clear"></div></div>
Brian Ray