jquery帮助布局

时间:2011-04-11 12:00:33

标签: javascript jquery css layout jquery-masonry

您好我有以下HTML,

    <article id="jobwall">
    <ul>
        <li class="box">Hello World</li>
        <li class="box">Hello World</li>
        <li class="box">Hello World</li>
        <li class="box noRMar">Hello World</li>
        <li class="box">Hello World</li>
        <li class="box">Hello World</li>
        <li class="box">Hello World</li>
    </ul>
</article>

以下CSS,

#jobwall { 
        width:100%;
        float:left;
        clear:both;
        overflow:hidden;
        margin:15px 0px 0px 0px;
    }   

    #jobwall li {
        width:221px;
        float:left;
        margin:0px 17px 20px 0px;
        border:1px solid red;

    }

        #jobwall li.noRMar {
            margin:0px 0px 20px 0px;
        }

我正在尝试为jquery实现一个名为Masonary的插件,这个想法是我可以让4 li的浮动彼此相邻,但是当我添加masonary时我只能浮动3,这是我的masonary设置,

$('#jobwall ul')。masonry({

          singleMode: false,
          // Disables measuring the width of each floated element.
          // Set to true if floated elements have the same width.
          // default: false

          columnWidth: 241,
          // Width in pixels of 1 column of your grid.
          // default: outer width of the first floated element.

          itemSelector: '.box:visible',
          // Additional selector to specify which elements inside
          // the wrapping element will be rearranged.
          // Required for Infinite Scroll with window resizing.

          resizeable: true,
          // Binds a Masonry call to window resizes 
          // so layout appears fluid.
          // default: true

          animate: true,
          // Animates layout rearrangements.
          // default: false

          saveOptions: true
          // Masonry will use the options from previous Masonry
          // calls by default, so you only have to enter in options once
          // default: true

        });

基本上我实现了masonary作为li,最终会显示更多内容会滑落,我需要li继续按照它们的顺序浮动。是否有更好的方法来实现这一点,或者是否允许4 li连续执行

1 个答案:

答案 0 :(得分:1)

页面上宽度大于100%的4 * 221px(+边距)?