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

javascript - Masonry is NOT filling small GAPS - Stack Overflow

programmeradmin1浏览0评论

DEMO

FULL Screen DEMO

Masonry is not filling small gaps even if there is space.

Example : Main Container width : 896px;

beside the first container with the orange background, there is a gap where Masonry could add one more container (Orange BG 2nd container), which is not happening. I'm not sure where I'm wrong. :-(

You need to maximize the window to see the issue.

JS :

jQuery(window).load(function() {
            /* var container = document.querySelector('.masonry-container');
            var msnry = new Masonry(container, {
                itemSelector: '.itemMas',
                columnWidth: 15,
                gutter: 1,
                isFitWidth: true
            }); 
             */
            $ = jQuery;
                var $container = $('.masonry-container').masonry();
                var msnry;
                $container.imagesLoaded( function(){
                    msnry = new Masonry( $container[0], {
                        itemSelector : '.itemMas',

                        isAnimated: true,
                        isFitWidth: true
                    });
                })
         }); 

DEMO

FULL Screen DEMO

Masonry is not filling small gaps even if there is space.

Example : Main Container width : 896px;

beside the first container with the orange background, there is a gap where Masonry could add one more container (Orange BG 2nd container), which is not happening. I'm not sure where I'm wrong. :-(

You need to maximize the window to see the issue.

JS :

jQuery(window).load(function() {
            /* var container = document.querySelector('.masonry-container');
            var msnry = new Masonry(container, {
                itemSelector: '.itemMas',
                columnWidth: 15,
                gutter: 1,
                isFitWidth: true
            }); 
             */
            $ = jQuery;
                var $container = $('.masonry-container').masonry();
                var msnry;
                $container.imagesLoaded( function(){
                    msnry = new Masonry( $container[0], {
                        itemSelector : '.itemMas',

                        isAnimated: true,
                        isFitWidth: true
                    });
                })
         }); 
Share edited Apr 10, 2015 at 7:26 caitlin 2,8294 gold badges31 silver badges65 bronze badges asked Apr 10, 2015 at 7:13 DeveloperDeveloper 1,4373 gold badges23 silver badges48 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

Masonry will not change the order of the elements in the document. It simply packs elements left-to-right as tightly as it can.

If you need to pack items by rearranging their layout, you want to use another library, such as Isotope (made by the same author). It features a bin-packing mode in which items can be rearranged to fit gaps.

Thanks for reporting this issue. This is how Masonry works. It may leave gaps. You should look at Packery, which was specifically designed to fill gaps.

发布评论

评论列表(0)

  1. 暂无评论