Margin塌陷解决方案

margin塌陷:子元素不能相对于父元素使用margin-top;其值必须大于父元素margin-top,而且父元素会随子元素一起移动。

解决方案:

1.设置父元素上边框(实际开发不提倡)

2.让父级元素触发bfc:

bcf触发条件:position:absolute ;

                       display:inline-block;

                       float:left/right;

                       overflow:hidden;

猜你喜欢

转载自blog.csdn.net/qq_45044074/article/details/112913816