css - 利润率问题,顶部利润率在底部利润率之上

标签 css margin

假设我有几个 <div> s,每个都有一个 margin-top和一个 margin-bottom .我希望这些元素一个接一个地排列:Top Margin -> Div -> Bottom Margin为每一个。 However, the top margin is "going over the bottom margin" ( fiddle )。所以每个元素之间的距离就是margin-top .

我找到了一种使用 float:left; 解决此问题的方法,但是我必须使用这个属性,绝对定位也不行。

PS:如果您在 fiddle 中看不到问题,请使用类似 Chrome 控制台的工具。

最佳答案

您所看到的称为 margin 崩溃。根据标准,这是正确的行为。

Margin does not push down another margin

关于css - 利润率问题,顶部利润率在底部利润率之上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4976227/

相关文章:

javascript - 如何制作具有许多层次结构/子子的水平下拉菜单?

css - 过渡在 Firefox 或 Opera 中不起作用,仅在 Chrome 中起作用

css - Safari 边距百分比错误

css - margin-top 值未被应用

css - @page :first { margin: . .. } 在 Chrome 错误中?

CSS Transform scale - 图像仍然占用空间

css - :hover an element with :active css loses the css

html - 使用负 margin 的替代方法?

css - 有什么方法可以使用纯 CSS 来制作按比例的边距吗?

html - CSS:背景颜色仅在边距内