最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jQuery masonry issue with display and height on load - Stack Overflow

programmeradmin0浏览0评论

I have a masonry container inside of a div that has display:none in inline style. Because I have a few divs, when the page loads it switches like a slideshow when their button is clicked. This interferes with masonry's ability to gauge the height on load so consequently the bricks spill out of the container.

I have a masonry container inside of a div that has display:none in inline style. Because I have a few divs, when the page loads it switches like a slideshow when their button is clicked. This interferes with masonry's ability to gauge the height on load so consequently the bricks spill out of the container.

Share Improve this question edited Aug 2, 2013 at 15:42 Roch 22.1k29 gold badges80 silver badges123 bronze badges asked May 29, 2011 at 18:16 nkcmrnkcmr 11k25 gold badges70 silver badges88 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

Update: the .load() part of my answer is not how this should be done.

See: http://masonry.desandro./layout.html#imagesloaded


You can fix it by:

  • Adding overflow: hidden to .panel to clear the floated elements inside.
  • Running Masonry on .load() instead of .ready():

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

Version with those fixes: http://jsbin./oyido4/4

发布评论

评论列表(0)

  1. 暂无评论