Equalize heights of div elements

Supplemental 688 views
0 Flares 0 Flares ×

Equalizing heights of div elements is not possible (or very hacky) to do in pure CSS, so jQuery is here to help. The code below will automatically adjust the heights of div elements according to the higher one.

var maxHeight = 0;

   if ($(this).height() > maxHeight) { maxHeight = $(this).height(); }


Or this can be condensed to one line:

var h = Math.max.apply(Math, $.map($(‘.el’),function(el){return $(el).height()}));

For Reference:

Equalize Heights of Divs

Provided by: CSS Tricks
Posted in jQuery


Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

No Trackbacks.


Register | Lost your password?
0 Flares Twitter 0 Facebook 0 Google+ 0 0 Flares ×