jQuery砌体问题显示和加载高度

时间:2011-05-29 18:16:16

标签: javascript css height jquery-masonry

我在div内部有一个砌体容器,内联样式为display:none。因为我有一些div,当页面加载时,它会在单击按钮时像幻灯片一样切换。这会干扰砌体测量负载高度的能力,因此砖块会从容器中溢出。

1 个答案:

答案 0 :(得分:6)

更新:我的答案的.load()部分不是应该如何完成的。

请参阅: http://masonry.desandro.com/layout.html#imagesloaded


你可以通过以下方式修复它:

  • overflow: hidden添加到.panelclear the floated elements内。
  • .load()而不是.ready()上运行砌体:

    <script type="text/javascript">
        $(document).load(function (){
          $('#contain').masonry({
            itemSelector: '.item',
            columnWidth: 100
          });
        });
    </script>
    

包含这些修正的版本:http://jsbin.com/oyido4/4