Created
March 31, 2013 18:37
-
-
Save michaelrog/5281552 to your computer and use it in GitHub Desktop.
jQuery width/height equalizer fn
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
/*-------------------------------------------------------------------- | |
* jQuery equalizer | |
* by Michael Rog | |
* | |
* based on the JQuery Plugins "EqualHeights" & "EqualWidths" | |
* by Scott Jehl, Todd Parker, Maggie Costello Wachs (http://www.filamentgroup.com) | |
*--------------------------------------------------------------------*/ | |
$.fn.equalizeHeights = function() { | |
var currentMax = 0; | |
$(this).each(function(i){ | |
window.log("equalizeHeights: comparing: " + $(this).height() + " vs " + currentMax); | |
if ($(this).height() > currentMax) { currentMax = $(this).height(); } | |
}); | |
window.log("equalizeHeights: max height for this set is " + currentMax); | |
// for ie6, set height since min-height isn't supported | |
if ($.browser.msie && $.browser.version == 6.0) { $(this).css({'height': currentMax}); } | |
$(this).css({'min-height': currentMax}).addClass("equalizer_HeightsEqualized"); | |
return this; | |
}; | |
$.fn.equalizeWidths = function() { | |
var currentMax = 0; | |
$(this).each(function(i){ | |
window.log("equalizeWidths: comparing: " + $(this).width() + " vs " + currentMax); | |
if ($(this).width() > currentMax) { currentMax = $(this).width(); } | |
}); | |
window.log("equalizeWidths: max width for this set is " + currentMax); | |
// for ie6, set width since min-width isn't supported | |
if ($.browser.msie && $.browser.version == 6.0) { $(this).css({'width': currentMax}); } | |
$(this).css({'min-width': currentMax}).addClass("equalizer_WidthsEqualized"); | |
return this; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment