Skip to content

Instantly share code, notes, and snippets.

@beaucharman
Last active December 20, 2015 03: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 beaucharman/6067575 to your computer and use it in GitHub Desktop.
Save beaucharman/6067575 to your computer and use it in GitHub Desktop.
Apply equal height to a group of provided elements, based on the tallest element
/**
* Equal Height
* ======================================================================== */
(function ($) {
$.fn.equalheight = function () {
var tallest = 0;
var height = 0;
//var offest = 0;
var $elements = $(this);
var resizeElements = function () {
tallest = 0;
height = 0;
$elements.each(function () {
//offset = $(this).offset().top;
//console.log(offset);
height = $(this).outerHeight();
if (height > tallest) {
tallest = height;
}
});
$elements.css('min-height', tallest);
};
resizeElements();
$(window).resize(function () {
resizeElements();
});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment