Jquery Isotope Masonry Layout leaves gap between elements in Bootstrap 3

微笑、不失礼 提交于 2019-12-08 11:19:19

问题


I am new to web development, especially Jquery and Bootstrap. I am trying to include Jquery Isotope to achieve a Pinterest like layout in one of the pages of my yet to be launched dream website, but I have run into few problems here. Since my html code is too long and I am in kind of in a hurry, I have made these .gif images that explain the problem better than my explanation below:

  1. The html elements I want to apply Isotope to come in a loop and seem to load properly upto only a few iterations. After that I can see a lot of gaps between the elements. If I try to resize the browser window, they rearrange themselves and everything is fine again [Please see image 1 to get a clear picture]. Note: This problem seems to exist only with the divs having Images. The text only elements are perfectly arranged.
  2. I want to the elements to re-arrange themselves if I remove any of them, which doesn't seem to work.
  3. Also, the elements are of variable heights and can be expanded in few conditions. I want the elements to rearrange themselves even in this case. [Please see image 2 to get a clear picture].

JS

if ($('#container').length) {
        $('#container').isotope({
            itemSelector: '.container-item',
            layoutMode: 'masonry'
        });
    }

Please help me solve these problems. Thanks in advance.


回答1:


It's hard to tell from the code and samples provided, but I think these are from default CSS margins or padding from masonry. When you open this in your browser, use your inspect element tool to see what classes are causing those gaps, then override that CSS. Wish I could be more help, but this is the best I can do with what is provided.




回答2:


What you are trying to achieve and what i have understood.Please have a look here

http://cssdeck.com/labs/css-only-pinterest-style-columns-layout



来源:https://stackoverflow.com/questions/29350317/jquery-isotope-masonry-layout-leaves-gap-between-elements-in-bootstrap-3

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