Nesting Masonry objects

风格不统一 提交于 2019-12-04 11:09:51
Grin

Consider this.

Remove itemSelector property - if the one is set Masonry will use not only children items but all descendants that match that selector. So, for the first container (motherContainer) Masonry would try to layout ALL .wrapper elements, include those in nested .container elements.

And the key point - call Masonry on the reverted array of .container elements. From the innermost to the outermost, because Masonry changes children elements' height leaving gaps in the parent container.

var $container = $('.container');
$($container.get().reverse()).masonry({});

Just give it a try. Here is a jsfiddle. I also added C elements.

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