目前位置
瀑布流效果Demo總結(3)之基於jquery+jquery.wookmark.js的實現
作者:sLoB    發佈於:    文字:【】【】【

1.綜述

    最近研究了時下流行的瀑布流展示效果。 目前共計嘗試的方法及其優缺點如下:

(1)基於JQuery框架及blocksit.min.js實現的瀑布流不連續,每列中多多少少都會有一些位置出現空白。
(2)基於JQuery框架,用匿名函數形式,自編程實現瀑布流
(3)基於CSS3,chrome、火狐、搜狗瀏覽器顯示正常,但IE8、IE10均不能顯示瀑布流 只能顯示單列照片,使用Web中介紹的ie-css3.htc或PIE元件仍不能在IE中顯示瀑布流效果
 (4)基於DIV 用<script>實現的瀑布流,本地瀑布流測試效果正常

 

2基於jquery+jquery.wookmark.js的實現

<!doctype html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

  <title>jQuery Wookmark Plug-in Example</title>
  <meta name="description" content="An very basic example of how to use the Wookmark jQuery plug-in.">
  <meta name="author" content="Christoph Ono">

  <meta name="viewport" content="width=device-width,initial-scale=1">

  <!-- CSS Reset -->
  <link rel="stylesheet" href="css/reset.css">
 
  <!-- Styling for your grid blocks -->
  <link rel="stylesheet" href="css/style.css">

</head>

<body>

  <div id="container">
    <header>
      <h1>jQuery Wookmark Plug-in Example</h1>
      <p>Resize the browser window or click a grid item to trigger layout updates.</p>
    </header>
    <div id="main" role="main">

      <ul id="tiles">
        <!-- These are our grid blocks -->
        <li><img src="images/image_1.jpg" width="200" height="283"><p>1</p></li>
        <li><img src="images/image_2.jpg" width="200" height="300"><p>2</p></li>
        <li><img src="images/image_3.jpg" width="200" height="252"><p>3</p></li>
        <li><img src="images/image_4.jpg" width="200" height="158"><p>4</p></li>
        <li><img src="images/image_5.jpg" width="200" height="300"><p>5</p></li>
        <li><img src="images/image_6.jpg" width="200" height="297"><p>6</p></li>
        <li><img src="images/image_7.jpg" width="200" height="200"><p>7</p></li>
        <li><img src="images/image_8.jpg" width="200" height="200"><p>8</p></li>
        <li><img src="images/image_9.jpg" width="200" height="398"><p>9</p></li>
        <li><img src="images/image_10.jpg" width="200" height="267"><p>10</p></li>
        <li><img src="images/image_1.jpg" width="200" height="283"><p>11</p></li>
        <li><img src="images/image_2.jpg" width="200" height="300"><p>12</p></li>
        <li><img src="images/image_3.jpg" width="200" height="252"><p>13</p></li>
        <li><img src="images/image_4.jpg" width="200" height="158"><p>14</p></li>
        <li><img src="images/image_5.jpg" width="200" height="300"><p>15</p></li>
        <li><img src="images/image_6.jpg" width="200" height="297"><p>16</p></li>
        <li><img src="images/image_7.jpg" width="200" height="200"><p>17</p></li>
        <li><img src="images/image_8.jpg" width="200" height="200"><p>18</p></li>
        <li><img src="images/image_9.jpg" width="200" height="398"><p>19</p></li>
        <li><img src="images/image_10.jpg" width="200" height="267"><p>20</p></li>
        <li><img src="images/image_1.jpg" width="200" height="283"><p>21</p></li>
        <li><img src="images/image_2.jpg" width="200" height="300"><p>22</p></li>
        <li><img src="images/image_3.jpg" width="200" height="252"><p>23</p></li>
        <li><img src="images/image_4.jpg" width="200" height="158"><p>24</p></li>
        <li><img src="images/image_5.jpg" width="200" height="300"><p>25</p></li>
        <li><img src="images/image_6.jpg" width="200" height="297"><p>26</p></li>
        <li><img src="images/image_7.jpg" width="200" height="200"><p>27</p></li>
        <li><img src="images/image_8.jpg" width="200" height="200"><p>28</p></li>
        <li><img src="images/image_9.jpg" width="200" height="398"><p>29</p></li>
        <li><img src="images/image_10.jpg" width="200" height="267"><p>30</p></li>
        <!-- End of grid blocks -->
      </ul>

    </div>
    <footer>

    </footer>
  </div>

  <!-- include jQuery -->
  <script src="js/jquery-1.7.1.min.js"></script>
 
  <!-- Include the plug-in -->
  <script src="js/jquery.wookmark.js"></script>
 
  <!-- Once the page is loaded, initalize the plug-in. -->
  <script type="text/javascript">
    $(document).ready(new function() {
      // 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: 2, // Optional, the distance between grid items
        itemWidth: 210 // Optional, the width of a grid item
      };
     
      // Get a reference to your grid items.
      var handler = $('#tiles li');
     
      // Call the layout function.
      handler.wookmark(options);
     
      // Capture clicks on grid items.
      handler.click(function(){
        // Randomize the height of the clicked item.
        var newHeight = $('img', this).height() + Math.round(Math.random()*300+30);
        $(this).css('height', newHeight+'px');
       
        // Update the layout.
        handler.wookmark();
      });
    });
  </script>
 
</body>
</html>

瀏覽 (4216) | 評論 (0) | 評分(0) | 支持(0) | 反對(0) | 發佈人:sLoB
將本文加入收藏夾
Search
美人時計
文章評論
最新評論
更多評論 發表評論
發表評論
您的評價
差(1) 一般(2) 好(3) 很好(4) 非常好(5)
評論標題
評論內容
驗 證 碼
看不清?更換一張
匿名發表 

© 2011 slobgame.net   website templates by styleshout      Powered by Wayhunt WebSite System 1.5