Skip to content

Instantly share code, notes, and snippets.

@Melindrea
Last active December 16, 2015 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Melindrea/5402738 to your computer and use it in GitHub Desktop.
Save Melindrea/5402738 to your computer and use it in GitHub Desktop.
jQuery Plugin for making boxes equal heights
// Window.load to avoid FOUC in some browsers
$(window).load( function() {
/* Make boxes same height */
$('.js-equal-height-columns-row').sameHeights();
});
/* Plugin to make variable height divs equal heights
http://www.cre8ivecommando.com/equal-height-columns-using-jquery-6164/
*/
$.fn.sameHeights = function () {
'use strict';
$(this).each(function () {
var tallest = 0;
$(this).children().each(function (i) {
if (tallest < $(this).height()) { tallest = $(this).height(); }
});
$(this).children().css({'height': tallest});
});
return this;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment