日期:2014-05-17  浏览次数:20420 次

关于瀑布流的一些问题php+js的
我从网上下载的瀑布流,弄了半天发现有个问题,



会出现 一列或者 两列 特别的长
非常不美观,我看了看代码,是在js里面判断位置并放进去新的内容的,代码如下:
$(document).ready(function(){
loadMore();
});

$(window).scroll(function(){
// 当滚动到最底部以上100像素时, 加载新内容


if ($(document).height() - $(this).scrollTop() - $(this).height()<100 && $(document).height()<5000) loadMore();

});


function loadMore()
{
$.ajax({
url : 'data.php',
dataType : 'json',
success : function(json){
if(!json){

return;
}else if(typeof json == 'object'){
var oProduct, $row, iHeight, iTempHeight;
for(var i=0, l=json.length; i<l; i++)
{
oProduct = json[i];

// 找出当前高度最小的列, 新内容添加到该列
iHeight = -1;
$('#stage li').each(function(){
iTempHeight = Number( $(this).height() );
if(iHeight==-1 || iHeight>iTempHeight)
{
iHeight = iTempHeight;
$row = $(this);
}
});

$(function(){
$(".wf-cld .btn").hide();
$(".wf-cld").hover(function(){
$(".btn",this).show();
},function(){
$(".btn",this).hide();
});
$(".drop").hide();
$(".per").hover(function(){
$(".drop").show();
},function(){
$(".drop").hide();
});
})




$item = $('<div class="wf-cld"><a href="goods.php?id='+oProduct.name+'" ><img src="/upload/'+oProduct.name+'.'+oProduct.format+'" ></a><div class="btn"><div class="like l"><a class="bj" href="#" >10000</a></div><a href="#"  class="share"><img src="/images/y2_16.png"></a><a href="#"  class="shoucang"><img src="/images/y2_18.png"></a><a href="#"  class="bj">123</a><a href="#"  class="bj">诱惑</a><a href="#"  class="bj">诱惑</a></div></div>').hide();



$row.append($item);
$item.fadeIn();
}
}
}
});
}


其中这段代码是检测在哪里插入新内容的:
// 找出当前高度最小的列, 新内容添加到该列
iHeight = -1;
$('#stage li').each(function(){
iTempHeight = Number( $(this).height() );
if(iHeight==-1 || iHeight>iTempHeight)
{
iHeight = iTempHeight;
$row = $(this);
}
});

这样就会出现上述图片的情况,我想修改成正常的,各位有没有什么好的方法呢??
谢谢大家 啊!

------解决方案--------------------
应该与你的整体布局有关
你最好贴出可供测试的代码
------解决方案-----------------