What the script do ?
Script will calculate the maximum height from the set of elements. While calculating it will consider the padding applied through CSS also . So have fun
How to call ?
$(document).ready(function(){ $(".my-equal-boxes").setEqualHeight(); });
JQuery extended function
jQuery.fn.setEqualHeight=function(o) { var maxHeight=0; var maxElement=null; jQuery(this).each(function(i) { if((jQuery(this).height()+parseInt(jQuery(this).css("padding-bottom"))+parseInt(jQuery(this).css("padding-top")))>maxHeight) { maxHeight=jQuery(this).height()+parseInt(jQuery(this).css("padding-top"))+parseInt(jQuery(this).css("padding-bottom")); maxElement=this; } }); jQuery(this).not($(maxElement)).each(function() {$(this).height(maxHeight-parseInt(jQuery(this).css("padding-top"))-parseInt(jQuery(this).css("padding-bottom")))}) }
#1 by Sunil - February 23rd, 2009 at 22:44
I am sure this will be very useful :). Need some time to experiment on this
#2 by Praveen Vijayan - February 23rd, 2009 at 22:48
Thanks yarr.. you save my day. It worked like magic. Thank you so much for your effort and for sharing this with rest of the community.
#3 by Driss lebbat - July 14th, 2009 at 05:58
Thanks, it help a lot.