tags:

views:

495

answers:

2

Ok, so I have this code:

<div class='layout' style='width: 500px;'>
  <div class='layout_frame' style='width: 300px;'></div>
  <div class='layout_frame' style='width: 200px;'></div>
  <div class='layout_frame' style='width: 100px;'></div>
  <div class='layout_frame' style='width: 300px;'></div>
  <div class='layout_frame' style='width: 100px;'></div>
</div>

Ok, so each DIV above is floated left, so what I get is two "rows" of DIV, the above row containing the first two, the second the three latter DIVs, right?

Ok, so each "layout_frame" can contain any content, so they will be of differing height, but I want the height to be equal WITHIN THE ROW. So the first two should perhaps both be 800px high, and the third latter should be, for example, 200px - based on the tallest DIV in the "row".

So I'm using jQuery position() to find out which ones that are in the same row, with this code:

var rows = new Array();
$("div.layout_frame").each(function(){
 var pos = $(this).offset().top;
 var height = $(this).height();
 if (height > rows[pos]){
  rows.pos = height;
 }
});

But that's as far as I've come. I'm setting "pos" to, say "124" which should be equal for the first two and not for the last three. But each "group" of DIVS should have the same height, based on the tallest.

I really hope I explained this correctly. Any help is appreciated

+2  A: 

you'd be better off laying it out like this:

<div class='layout' style='width: 500px;'>
  <div class='layout_frame' style='width: 300px;'></div>
  <div class='layout_frame' style='width: 200px;'></div>
</div>
<div class='layout' style='width: 500px;'>
  <div class='layout_frame' style='width: 100px;'></div>
  <div class='layout_frame' style='width: 300px;'></div>
  <div class='layout_frame' style='width: 100px;'></div>
</div>

then looking at whichever child div of each layout has the largest height, and set all of them to that height.

GSto
No, I will not be doing it this way. I want to solve it from the explanation in my OP, but thanks anyway
Sandman
But his way does make more sense and would be easier...
qui
A: 

For the moment, I have this code corresponding to your needs: I will update the code according to your wishes.

<html>
<head>
<title>frame layout</title>
<style  type="text/css"> 
div
{
    border: 1px solid black;
    height: 25px;
    float: left;
}
.layout
{
    border: 2px solid red;
}
</style>
</head>
<body>

<div class='layout' style='width: 500px;'>
  <div class='layout_frame' style='width: 300px;'>div1</div>
  <div class='layout_frame' style='width: 200px;'>div2</div>
  <div class='layout_frame' style='width: 100px;'>div3</div>
  <div class='layout_frame' style='width: 300px;'>div4</div>
  <div class='layout_frame' style='width: 100px;'>div5</div>
</div>
</body>
</html>
enguerran
That breakes up the DIV in two parents, and as such is not something I can use. These are all in the same DIV
Sandman
Ok, I changed it...May be you can add another class (class='layout_frame div1_height' and class='layout_frame div2_height') to change in the same way the two sets of div (using javascript to change css values)?
enguerran
Well, the width is dynamic, so maybe one of the DIVS will grow and shrink so that DIV3 all of a sudden fits in row 1, this is all dynamic, so I need to update the heights as it changes.
Sandman
ok. What you have to know is that IE or firefox (maybe others) do not calculate border and margin in the same way: one includes border in the width calculation, the other count it apart...Maybe you can find something already done here : http://www.dynamicdrive.com/style/layouts/category/C13/
enguerran