基于Jquery的瀑布流
AJAX
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
$size = 20;
try
{
$pdo = new PDO('mysql:host=localhost;dbname=wechatbook', 'root', 'root');
$offset = ($page - 1) * $size;
$sql = "SELECT title FROM wcb_rss_news limit $offset,$size";
$stmt = $pdo->query($sql);
$stmt->setFetchMode(PDO::FETCH_ASSOC);
$list = $stmt->fetchAll();
if (!empty($list))
{
foreach ($list as $row)
{
?>
= $row['title'] ?>
}
}
else
{
echo '';
}
}
catch (PDOException $e)
{
}
?>
<script><li> $(function() {<li> var $container = $("#container");<li> $container.imagesLoaded(function() {<li> $container.masonry({<li> itemSelector: '.box',<li> isAnimated: true,<li> columnWidth:200,<li> gutterWidth:200,<li> // isFitWidth:true,//自适应宽度<li> isResizableL:true// 是否可调整大小<li> });<li> });<li> $container.infinitescroll({<li> navSelector: '#next-link',<li> nextSelector: '#next-link a',<li> itemSelector: '.box',<li> animate: true,<li> loading: {<li> msgText: "加载中...",<li> finishedMsg: '没有新数据了...',<li> img: 'http://xialei.test.com/img/loading.gif',<li> selector: '.loading'<li> },<li> localMode: true<li> }, function(newElements) {<li> console.dir(newElements)<li> var $newEle = $(newElements);<li> $newEle.imagesLoaded(function() {<li> $container.masonry('appended', $newEle, true);<li> });<li> });<li> });<li></script>
复制代码