关于瀑布流的一些有关问题php+js的

WBOY
Release: 2016-06-13 11:25:50
Original
786 people have browsed it

关于瀑布流的一些问题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 {
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 = $('').hide();



$row.append($item);
$item.fadeIn();
}
}
}
});
}
Copy after login


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

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!