Skip to content

Instantly share code, notes, and snippets.

@stephenbelyea
Created March 2, 2016 02:08
Show Gist options
  • Save stephenbelyea/2529ec313f34075cec18 to your computer and use it in GitHub Desktop.
Save stephenbelyea/2529ec313f34075cec18 to your computer and use it in GitHub Desktop.
Set equal height items in a row.
var setEqualRows = function(){
$('[data-equal-row]').each(function(){
var items = $(this).find('[data-equal-item]'),
maxHeight = 0;
items.css('min-height','auto');
setTimeout(function(){
items.each(function(){
var thisHeight = $(this).outerHeight();
console.log(thisHeight);
maxHeight = (thisHeight > maxHeight)? thisHeight : maxHeight;
});
items.css('min-height', maxHeight+'px');
}, 10);
});
};
if ( $('[data-equal-row] [data-equal-item]').length ) {
setEqualRows();
$(window).on('resize', setEqualRows);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment