Last active
January 14, 2016 00:07
-
-
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.
This file contains 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
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