html - 使用 CSS 显示不同尺寸的 div

标签 html css

如何显示不同高度的div,使其彼此靠近,而不管其高度如何,并且具有特定的边距,就像建筑物一样
我的意思是类似于本网站中的 div http://via.me
我使用了 flaot:left 但它只与最后一个 div 一起 float 并留下一个空白空间 这是我使用的代码 http://jsfiddle.net/D9rHB/6/

最佳答案

我认为 jQuery Masonry在这种情况下,插件将是您要查找的内容:

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 .

关于html - 使用 CSS 显示不同尺寸的 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11387625/

相关文章:

html - 背景响应问题

css - div 在另一个中间

javascript - onSubmit 在任何浏览器中都不起作用

html - 为什么我的输入框被强制到另一行?

html - CSS 翻转图像

html - 删除 Div 之间的间距

css - 为什么包装 div 不会围绕 float 元素展开?

javascript - 在一页上加载 1000 张图片

javascript - 如何修复动画类的一部分?

html - 聚焦时如何使输入宽度更大并高于植物?