瀑布流的图片是重叠的?
$(function(){
waterfall();
})
function waterfall(){
var $parent=$("#wrap");
var $box=$("#wrap>div");
var w=$box.eq(0).outerWidth();
//alert(w);
var cols=Math.floor($(window).width()/w);
$parent.css("width",cols*w);
var picArr=[];
$box.each(function(index,value){
var h=$box.eq(index).outerHeight();
if(index<cols){
picArr[index]=h;
//picArr.push(h);
}else{
var minH=Math.min.apply(null,picArr);
var minHIndex=$.inArray(minH,picArr);
$(value).css({
"position":"absolute",
"top":minH+"px",
"left":w*minHIndex+"px"
})
picArr[minHIndex] += $box.eq(index).height()+10;
}
})
}jQuery代码是这样的,和老师敲的基本一样,可是重叠了?想不明白为什么?