首页 >后端开发 >php教程 >基于Jquery的瀑布流

基于Jquery的瀑布流

WBOY
WBOY原创
2016-07-25 08:48:271272浏览
基于Jquery的瀑布流
  1. AJAX
  2. $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
  3. $size = 20;
  4. try
  5. {
  6. $pdo = new PDO('mysql:host=localhost;dbname=wechatbook', 'root', 'root');
  7. $offset = ($page - 1) * $size;
  8. $sql = "SELECT title FROM wcb_rss_news limit $offset,$size";
  9. $stmt = $pdo->query($sql);
  10. $stmt->setFetchMode(PDO::FETCH_ASSOC);
  11. $list = $stmt->fetchAll();
  12. if (!empty($list))
  13. {
  14. foreach ($list as $row)
  15. {
  16. ?>
  17. = $row['title'] ?>
  18. }
  19. }
  20. else
  21. {
  22. echo '';
  23. }
  24. }
  25. catch (PDOException $e)
  26. {
  27. }
  28. ?>
  • <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>
  • 复制代码


  • 声明:
    本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn