jQuery or JavaScript to make DIV columns same height across across several containers -


i have number of container divs each holding other column divs, have tried javascript script make half column divs resize @ same height. has worked means other half divs on page resize height. see screenshot below. half divs have same id in different containers. there jquery or javascript code can resize height across divs within each individual container?

in screen shot top row 1 container, bottom row has div within different container. want bottom row div resize match height of tallest div within separate container. want workout several containers resize inner divs across page.

enter image description here

part of code:

<style> #page{width:85%; text-align:center;margin:auto;} #row{width:100%;background:yellow;margin-bottom:1%;} #container{height: auto;display: table;float:left;} #header{width:100%;background-color: rgb(0, 143, 213); height:50px;} #full{width:99%;margin:0.5%;background-color:skyblue;} .half{width:48%; margin:0.5%;padding:0.5%;float:left; background-color:#1589ff;display: table-cell;} #third{width:32.333%; float:left; margin:0.5%; background-color:skyblue;} #th2{width:65.66%; float:left; margin:0.5%; background-color:skyblue;} #quarter{width:23%; margin:0.5%;padding:0.5%; float:left; background-color:blue;height:100px}  </style>  <script type='text/javascript'> $(window).load(function(){ $(window).resize( function() {  var $column = $('.column'),     maxheight = 0;  $column.each( function() {     $(this).removeattr('style');     if($(this).height() > maxheight) {         maxheight = $(this).height();     }  });  $column.height(maxheight);  }).trigger('resize'); });    </script>  </head> <body>  <div id="full">menu</div> <div id="th2">2/3</div><div id="third">third</div> <div id="container"> <div class="half column"><h1>about</h1><p>lorem ipsum dolor sit amet, consectetur adipiscing elit. aliquam sodales urna non odio egestas tempor. nunc vel vehicula ante. etiam bibendum iaculis libero, eget molestie nisl pharetra in. in semper consequat est, eu porta velit mollis nec.  lorem ipsum dolor sit amet, consectetur adipiscing elit. aliquam sodales urna non odio egestas tempor. nunc vel vehicula ante. etiam bibendum iaculis libero, eget molestie nisl pharetra in. in semper consequat est, eu porta velit mollis nec. curabitur posuere enim eget turpis feugiat tempor. etiam ullamcorper lorem dapibus velit suscipit ultrices. proin in est sed erat facilisis pharetra.</div> <div class="half column"><h1>news</h1><p>lorem ipsum dolor sit amet, consectetur adipiscing elit. aliquam sodales urna non odio egestas tempor. nunc vel vehicula ante. etiam bibendum iaculis libero, eget molestie nisl pharetra in. in semper consequat est, eu porta velit mollis nec.  lorem ipsum dolor sit amet, consectetur adipiscing elit. aliquam sodales urna non odio egestas tempor. nunc vel vehicula ante. etiam bibendum iaculis libero, eget molestie nisl pharetra in.    </div> </div>  <div id="container2"> <div class="half column">half<br>more info</div><div id="quarter">quarter</div><div id="quarter">quarter</div> </div>  </div> 

one solution problem if don't want write 1 line each container , loop through columns either change class container on elements id containerx. like:

$('.container').each(function(index, elem){   var maxheight;   $(elem).find('.column').each(function(index, elem) {     var height = $(elem).height();     if(height > maxheight)       maxheight = height;   });   $(elem).find('.column').height(maxheight); }); 

there can syntax error should see i'm trying here. in way resize columns inside current container looping through. wonder; have tried setting height of columns 100%? should never bigger it's parent anyway wont fill whole page if not necessary.

good luck!


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -