Return to Snippet

Revision: 26331
at September 20, 2010 20:25 by lawlesscreation


Updated Code
//EQUAL HEIGHT COLUMNS
/** 
 * @description	Simple Equal Columns
 * @author 	Matt Hobbs modified by Matt Lawson
 * @version 	0.02 
 */
jQuery.fn.equalCols = function(){
	//Array Sorter
	var sortNumber = function(a,b){return b - a;};
	var heights = [];
	//Push each height into an array
	$(this).each(function(){
	    heights.push($(this).height());
	});
	heights.sort(sortNumber);
	var maxHeight = heights[0];
	return this.each(function(){
	    //Set each column to the max height
	    if ($.browser.msie && $.browser.version <= 6 ) {
	        $(this).css({'height': maxHeight});
	    } else {
	        $(this).css({'min-height': maxHeight});
	    }
	});
};

/* Usage */
jQuery(function($){
	$('.homePage .threeColumnLayout .box').equalCols();
	$('.homePage .twoColumnLayout .box').equalCols();
});

Revision: 26330
at April 23, 2010 08:41 by lawlesscreation


Initial Code
//EQUAL HEIGHT COLUMNS
/** 
 * @projectDescription	Simple Equal Columns
 * @author 	Matt Hobbs
 * @version 	0.01 
 */
jQuery.fn.equalCols = function(){
	//Array Sorter
	var sortNumber = function(a,b){return b - a;};
	var heights = [];
	//Push each height into an array
	$(this).each(function(){
		heights.push($(this).height());
	});
	heights.sort(sortNumber);
	var maxHeight = heights[0];
	return this.each(function(){
		//Set each column to the max height
		if ($.browser.msie && $.browser.version <= 6 ) {
			$(this).css({'height': maxHeight});
		} else {
			$(this).css({'min-height': maxHeight});
		}
	});
};

jQuery(function($){
	$('.homePage .threeColumnLayout .box').equalCols();
	$('.homePage .twoColumnLayout .box').equalCols();
	$('.contentBlock .twoColumnLayout:first-child .box').equalCols();
	$('.contentBlock .twoColumnLayout:nth-child(2) .box').equalCols();
});

Initial URL

                                

Initial Description

                                

Initial Title
Equal height columns

Initial Tags
jquery

Initial Language
jQuery