Last active
August 29, 2015 13:56
-
-
Save natejacobson/8969689 to your computer and use it in GitHub Desktop.
A Column Equalizer
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
$(document).ready(function(){ | |
function equalizing() { | |
if( $('.equalize').length ) { | |
$('.row.equalize .column').css('min-height',''); | |
$('.row.equalize').each(function(){ | |
var tallestBox = 0; | |
$('.column', this).each(function(){ | |
if($(this).height() > tallestBox) { | |
tallestBox = $(this).outerHeight(); | |
} | |
}); | |
$('.column',this).not('.unequaled').css('min-height',tallestBox); | |
$('section.equalize .column',this).css('min-height','auto'); | |
}); | |
} | |
} | |
equalizing(); | |
$(window).resize(function(){ equalizing(); }); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is probably the first piece of Javascript I've tweaked to the point that I think others could benefit from my contribution, so here you go. See http://jsfiddle.net/nathanbjacobson/6GwXA/1/. It started here http://stackoverflow.com/questions/11688250/setting-equal-heights-for-divs-with-jquery/11688385#11688385.