// jQuery wrapper(function($){// Run again when all page (and all images) fully loaded$(window).load(function(){equalheight('.grid .item');});// Run on window resize$(window).resize(function(){equalheight('.grid .item');});// Equal Heightsequalheight=function(container){varcurrentTallest=0,currentRowStart=0,rowDivs=newArray(),$el,topPosition=0;$(container).each(function(){$el=$(this);$($el).height('auto')topPosition=$el.position().top;if(currentRowStart!=topPosition){for(currentDiv=0;currentDiv<rowDivs.length;currentDiv++){rowDivs[currentDiv].height(currentTallest);}rowDivs.length=0;// empty the arraycurrentRowStart=topPosition;currentTallest=$el.height();rowDivs.push($el);}else{rowDivs.push($el);currentTallest=(currentTallest<$el.height())?($el.height()):(currentTallest);}for(currentDiv=0;currentDiv<rowDivs.length;currentDiv++){rowDivs[currentDiv].height(currentTallest);}});}});// End jQuery Wrapper
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.