Skip to content

Instantly share code, notes, and snippets.

@JTLR
Created January 23, 2014 12:42
Show Gist options
  • Save JTLR/b3cb1acc0687e05d462d to your computer and use it in GitHub Desktop.
Save JTLR/b3cb1acc0687e05d462d to your computer and use it in GitHub Desktop.
Equal heights JS function using css height inheritance for child elements
var height;
$(window).bind('load resize', function() {
height = 0;
$('.equal-height').each(function() {
$(this).css('height', 'auto');
$(this).children().each(function() {
if($(this).height() > height) {
height = $(this).height();
}
});
$(this).css('height', height);
height = 0;
});
});
.equal-height {
> * {
height: inherit;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment