与演示相比,同位素砌体产生不同的输出

时间:2016-12-16 15:24:17

标签: javascript jquery html css jquery-isotope

我正在努力学习Isotope。我正在尝试一个特定的演示,我已经复制了给定fiddle here

的代码

但是,输出是不同的。

  1. 我的输出: enter image description here

  2. 演示网站上的输出: enter image description here

  3. 浏览器已最大化,我在同一屏幕上查看。这是我页面上的代码:

      <html>
    <head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style type="text/css">
        * { box-sizing: border-box; }
    
        body { font-family: sans-serif; }
    
        /* ---- grid ---- */
    
        .grid {
            background: #DDD;
            max-width: 1200px;
        }
    
        /* clear fix */
        .grid:after {
            content: '';
            display: block;
            clear: both;
        }
    
        /* ---- .grid-item ---- */
    
        .grid-item {
            float: left;
            width: 100px;
            height: 100px;
            margin-bottom: 20px;
            background: #0D8;
            border: 2px solid #333;
            border-color: hsla(0, 0%, 0%, 0.7);
        }
    
        .grid-item--width2 { width: 220px; }
        .grid-item--height2 { height: 220px; }
    
    </style>
    
    </head>
    <body>
    <h1>Isotope - masonry gutter, with margin bottom</h1>
    
    <div class="grid">
        <div class="grid-item grid-item--width2"></div>
        <div class="grid-item grid-item--height2"></div>
        <div class="grid-item"></div>
        <div class="grid-item"></div>
        <div class="grid-item grid-item--width2 grid-item--height2"></div>
        <div class="grid-item grid-item--width2"></div>
        <div class="grid-item grid-item--width2"></div>
        <div class="grid-item grid-item--height2"></div>
        <div class="grid-item"></div>
        <div class="grid-item grid-item--width2"></div>
        <div class="grid-item grid-item--height2"></div>
        <div class="grid-item"></div>
        <div class="grid-item"></div>
    </div>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
    <script type="text/javascript" src="https://npmcdn.com/isotope-layout@3.0.1/dist/isotope.pkgd.js"></script>
    <script type="text/javascript">
    
    
        $('.grid').isotope({
            itemSelector: '.grid-item',
            masonry: {
                columnWidth: 100,
                gutter: 20
            }
        });
    </script>
    </body>
    </html>

1 个答案:

答案 0 :(得分:0)

尚未插入Jquery。感谢@MostafaBaezid的提示。