Created
January 23, 2014 12:42
-
-
Save JTLR/b3cb1acc0687e05d462d to your computer and use it in GitHub Desktop.
Equal heights JS function using css height inheritance for child elements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.equal-height { | |
> * { | |
height: inherit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment