Created
March 2, 2016 02:08
-
-
Save stephenbelyea/2529ec313f34075cec18 to your computer and use it in GitHub Desktop.
Set equal height items in a row.
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
var setEqualRows = function(){ | |
$('[data-equal-row]').each(function(){ | |
var items = $(this).find('[data-equal-item]'), | |
maxHeight = 0; | |
items.css('min-height','auto'); | |
setTimeout(function(){ | |
items.each(function(){ | |
var thisHeight = $(this).outerHeight(); | |
console.log(thisHeight); | |
maxHeight = (thisHeight > maxHeight)? thisHeight : maxHeight; | |
}); | |
items.css('min-height', maxHeight+'px'); | |
}, 10); | |
}); | |
}; | |
if ( $('[data-equal-row] [data-equal-item]').length ) { | |
setEqualRows(); | |
$(window).on('resize', setEqualRows); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment