Wookmark-jQuery-master 瀑布流外掛程式使用介紹,含個人測試DEMO

來源:互聯網
上載者:User

標籤:des   style   class   blog   code   java   

要求
    • 必備知識

      本文要求基本瞭解 Html/CSS,  JavaScript/JQuery。

    • 開發環境

      Dreamweaver CS6 / Chrome瀏覽器

    • 示範地址

      示範地址 資料下載

 

 

測試預覽(抬抬你的滑鼠就可以看到示範地址哦):

程式核心代碼看這裡:

$(function(){            function show(){                    var colors=["#BA4A3A","#5BB5D6","#8EA83B","#EE5C92","#8AC9B5","#604127","#E8A03B","#AF032D","#000000","#506575"];                var tags=["女人","男人","電影","寶兒","安妮海瑟薇","數位"];                for(var i in colors){                    var index = Math.round(Math.random() * 59);                    var img="../Public/Pic/test/"+index+".jpg";                    var index2=Math.round(Math.random() * (tags.length-1));  //隨機擷取一個標籤                                    $(‘#tiles‘).append(" <li style=‘background:"+colors[i]+"‘ class=‘clearFix‘><div style=‘background:#FFF‘><img src=‘"+img+"‘ width=‘230‘ /></div><p>是一個熊!!不是一個遊戲機!!</p><span>#"+tags[index2]+"</span></li> ");                }                }                 //初始化二十條資料         show();         show();                    /*瀑布流*/    $(‘#tiles‘).imagesLoaded(function() {        var handler = null;        // Prepare layout options.        var options = {          autoResize: true, // This will auto-update the layout when the browser window is resized.          container: $(‘#main‘), // Optional, used for some extra CSS styling          offset: 15, // Optional, the distance between grid items          itemWidth: 230, // Optional, the width of a grid item          direction :‘right‘        };                //瀑布流布局        function applyLayout() {          $(‘#tiles‘).imagesLoaded(function() {            // Destroy the old handler        //是否需要銷毀舊的布局            if (handler.wookmarkInstance) {              handler.wookmarkInstance.clear();            }            // Create a new layout handler. //重新布局瀑布流            handler = $(‘#tiles li‘);            handler.wookmark(options);    //傳入配置參數          });        }          //當捲軸高度大於等於最後一個盒子高度 Ajax請求資料          //綁定到scroll事件上                 function onScroll(event) {          // Check if we‘re within 100 pixels of the bottom edge of the broser window.          var winHeight = window.innerHeight ? window.innerHeight : $(window).height(); // iphone fix          var closeToBottom = ($(window).scrollTop() + winHeight > $(document).height() - 100);          if (closeToBottom) {                show();            applyLayout();  //執行布局          }        };        // Capture scroll event.        $(window).bind(‘scroll‘, onScroll);        // Call the layout function.        handler = $(‘#tiles li‘);  //擷取盒子        handler.wookmark(options);    //初始化瀑布流      });                        });
 

Wookmark-jQuery瀑布流外掛程式介紹和下載:http://www.wookmark.com/jquery-plugin/

 

官方線上示範地址:http://www.wookmark.com/

 

 

關於動態上傳圖片將到後續的文章中介紹,有興趣的博友可以多多關注哦!!

“呵呵”結束了,請原諒本童鞋目前”腦殘又缺乏”的語言群組織能力,歡迎大家來拍磚來劈斧,由於本人水平有限,文章在表述和代碼方面如有不妥之處,歡迎批評指正。

 

如以上文章或連結對你有協助的話,別忘了在文章結尾處輕輕點擊一下 “還不錯”按鈕或到頁面右下角點擊 “贊一個” 按鈕哦。你也可以點擊頁面右邊“分享”懸浮按鈕哦,讓更多的人閱讀這篇文章。

 

作者:Li-Cheng出處: http://www.cnblogs.com/Li-Cheng/p/3807592.html由於本人水平有限,文章在表述和代碼方面如有不妥之處,歡迎批評指正。留下你的腳印,歡迎評論哦。你也可以關注我,一起學習哦!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.