I know this question has been asked a million times, but I'm looking for something more specific.
Since my site is completely responsive, I need divs to change depending on each row, rather than setting everything to the same height.
I use the following modified code to set the height of all divs in a container:
$.fn.eqHeights = function() { var el = $(this); if (el.length > 0 && !el.data('eqHeights')) { $(window).bind('resize.eqHeights', function() { el.eqHeights(); }); el.data('eqHeights', true); } return el.each(function() { var curTop = 0; var curHighest = 0; $(this).children().each(function(indx) { var el = $(this), elHeight = el.height('auto').outerHeight(); var thisTop = el.position().top; if (curTop > 0 && curTop != thisTop) { curHighest = 0; } if (elHeight > curHighest) { curHighest = elHeight; } curTop = thisTop; }).height(curHighest); }); };
I have var thisTop = el.position().top; to determine which elements are on the same line, but I'm not sure how I can set all the elements on the same line with the highest value?
Currently .height(curHighest); sets all elements to the same height regardless of whether they are on the same line or not.
Thanks for the help in this.
javascript jquery responsive-design
dclawson
source share