Skip to content

Instantly share code, notes, and snippets.

@spsaucier
Last active December 29, 2015 09:39
Show Gist options
  • Save spsaucier/7651636 to your computer and use it in GitHub Desktop.
Save spsaucier/7651636 to your computer and use it in GitHub Desktop.
jQuery function to equalize heights of a set of elements. HTML structure for example call: div.equalize>div*4
$(window).on('load resize', function(){
$('.equalize > *').equalHeights();
});
$.fn.equalHeights = function() {
var maxHeight = 0,
$this = $(this);
$this.each( function() {
$(this).css('min-height', 'none');
var height = $(this).outerHeight();
if ( height > maxHeight ) { maxHeight = height; }
});
return $this.css('min-height', maxHeight);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment