有时两个边距会折叠成一个边距。
元素的顶部和底部边距有时会折叠成单个边距,该边距等于两个边距中最大的一个。
这不会发生在左右边缘!只有顶部和底部边距!
看下面的例子:
在上面的示例中,<h1> 元素的下边距为 50 像素,<h2> 元素的上边距设置为 20 像素。
常识似乎表明 <h1> 和 <h2> 之间的垂直边距总计为 70 像素 (50 像素 + 20 像素)。但由于边距塌陷,实际边距最终为 50px。
Property | Description |
---|---|
margin | A shorthand property for setting all the margin properties in one declaration |
margin-bottom | Sets the bottom margin of an element |
margin-left | Sets the left margin of an element |
margin-right | Sets the right margin of an element |
margin-top | Sets the top margin of an element |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!