首页 > 开发 > PHP > 正文

thinkPHP实现瀑布流的方法

2024-05-04 22:17:04
字体:
来源:转载
供稿:网友

本文实例讲述了thinkPHP实现瀑布流的方法。分享给大家供大家参考。具体分析如下:

很多人都想做瀑布流的效果,这里告诉大家官网使用的方法,首先要下载瀑布流的插件jquery.masonry.min.js 地址:http://masonry.desandro.com/index.html里面包含的很多示例.

流程:

1. 页面初始化时,调用插件进行一次排版;

2. 当用户将滚动条拖到底部时,用ajax加载一次数据,并排版显示

3. 重复2,直到无数据

Html代码:
代码如下:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>Insert title here</title> 
<!--样式--> 
<style type="text/css"> 
body {margin:40px auto; width:800px; font-size:12px; color:#666;} 
.item{ 
border: 1px solid #D4D4D4; 
color: red; 
margin: 0 10px 10px 0; 
padding: 10px; 
position: relative; 
width: 200px; 

.loading-wrap{ 
bottom: 50px; 
width: 100%; 
height: 52px; 
text-align: center; 
display: none; 

.loading { 
padding: 10px 10px 10px 52px; 
height: 32px; 
line-height: 28px; 
color: #FFF; 
font-size: 20px; 
border-radius: 5px; 
background: 10px center rgba(0,0,0,.7); 

.footer{ 
border: 2px solid #D4D4D4; 

</style> 
<!--样式--> 
</head> 
<body> 
<!--引入所需要的jquery和插件--> 
<script type="text/javascript" src="/test/public/Js/jquery-1.7.2.min.js"></script> 
<script type="text/javascript" src="/test/public/Js/jquery.masonry.min.js"></script> 
<!--引入所需要的jquery和插件--> 
<!--瀑布流--> 
<div id="container" class=" container"> 
<!--这里通过设置每个div不同的高度,来凸显布局的效果--> 
<volist name="height" id="vo"> 
<div class="item" style="height:{$vo}px;">瀑布流下来了</div> 
<input type="hidden" name="last_id" class="last_id" value="{$vo.id}"/> 
</volist> 
</div> 
<!--瀑布流--> 
<!--加载中--> 
<div id="loading" class="loading-wrap"> 
<span class="loading">加载中,请稍后...</span> 
</div> 
<!--加载中--> 
<!--尾部--> 

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表