Masonry images overlapping above each other

后端 未结 1 2072
北荒
北荒 2020-12-10 04:06

I am working on a masonry layout for an image gallery. But masonry most of the time displays images overlapped on one another. Rest of the time its ok and sometimes some ima

相关标签:
1条回答
  • 2020-12-10 04:59

    First use imagesLoaded :

    // with jQuery
    var $container = $('#container');
    
    // initialize Masonry after all images have loaded  
    $container.imagesLoaded( function() {
         $container.masonry();
    });
    

    then, if you can, specify the image width/height attributes on image tag

    <img src="...." width="200" height="200" />
    

    imagesLoaded is not deprecated:

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

    0 讨论(0)
提交回复
热议问题