Last active
December 20, 2015 03:59
-
-
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
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
/** | |
* 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