Display divs with different sizes with CSS

后端 未结 2 1856
深忆病人
深忆病人 2021-01-24 17:42

how can I display divs with different height to be close to each other regardless of its height and with a specific margin just like buildings
I mean something like the div

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-24 18:22

    I think that the jQuery Masonry plugin would be what you're looking for in this instance:

    Masonry is a dynamic grid layout plugin for jQuery. Think of it as the flip-side of CSS floats. Whereas floating arranges elements horizontally then vertically, Masonry arranges elements vertically, positioning each element in the next open spot in the grid. The result minimizes vertical gaps between elements of varying height, just like a mason fitting stones in a wall.

    JS Fiddle demo.

提交回复
热议问题