Skip to content

Instantly share code, notes, and snippets.

@neutraltone
Last active January 14, 2016 00:07
Show Gist options
  • Save neutraltone/8820372 to your computer and use it in GitHub Desktop.
Save neutraltone/8820372 to your computer and use it in GitHub Desktop.
This piece of jQuery will calculate the height of columns and resize the shorter ones to be the same height as the tallest one.
function equalCols() {
$('.js-cols').each(function() {
var tallestCol = 0;
currentHeight;
$(this).find('.js-col').each(function() {
$(this).css('height', 'auto');
currentHeight = $(this).height('auto').height();
if (currentHeight > tallestCol) {
tallestCol = currentHeight;
}
}).css('height', tallestCol);
});
}
$(window).load(function() {
$(this).resize();
}).resize(function() {
equalCols();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment