Masonry images overlapping issue

泪湿孤枕 提交于 2019-11-27 19:55:46
 jQuery(function(){
   var $container = $('#container');
   $container.imagesLoaded( function () {
       itemSelector: '.box',
       animate: true
   });
  });

Source: jQuery Masonry Images

I've experienced the same problem and I developed 2 methods to combat it. First off reload the container after you have appended the onclick-image.

1. container.masonry('reload');

Second, and probably more important, dynamically correct the height of the surrounding div to match the height of the image:

2. // bricks correct height
   var brick = $("#marker #container .brick"); 
   brick.each(function() {
          var content = $(this).find(">div");
          var img = $(this).find("img");
           content.css({
            height: img.attr("height")
           });
        });

So my brick is looking like this:

  <div style="height: 284px; position: static; top: -133px;" class="test">  
       <a class="arrow" href="#" target="_self"><img class="img" src="test.jpg" width="374" height="284"></a>
  </div>

Edit: In your code you have the same problem, there is no height in the style.

<div style="position: absolute; left: 330px; top: 280px;" class="box item 3d">

And it seems to me you have a problem with the width, too. I think you need to use a smaller width for the column. A good value would be the width of the small image and some border.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!