for(var i = 0; i < aBox.length; i++) {
if(i < cnum) {
aBox[i].style.top = 0 + 'px';
aBox[i].style.left = boxwidth * i + 'px';
aBoxHeight.push(aBox[i].offsetHeight);
}
else {
var minHeight = Math.min.apply(null,aBoxHeight);
var minIndex = getIndex(aBoxHeight,minHeight);
aBox[i].style.position = 'absolute';
aBox[i].style.top = minHeight+'px';
aBox[i].style.left = aBox[minIndex].offsetLeft+'px';
aBoxHeight[minIndex] +=aBox[i].offsetHeight;
}
}
aBox[i].style.top = 0 + 'px';前面为什么不加上一句 aBox[i].style.position = 'absolute';第一行以外的图片定位都加了的
回夢
相关分类