$(function(){
waterfall();
});
var waterfall = function(){
var $boxs = $("#main>div");
var w = $boxs.eq(0).outerWidth();
//获取列数
var cols = Math.floor($(window).width()/w);
var total = w*cols;
$("#main").width(total);
var hArr = [];
$boxs.each(function(index,value){
var h = $boxs.eq(index).outerHeight();
if(index
hArr[index] = h;
}else{
var minH = Math.min.apply(null,hArr);
var minHindex = $.inArray(minH,hArr);
$(value).css({
'position':'absolute',
'top':minH+'px',
'left':minHindex*w+'px'
});
hArr[minHindex] += $boxs.eq(index).outerHeight();
}
})
}