-
padding:
-
margin:
-
可以理解为两个盒子的距离既为margin。
- margin塌陷问题
-
- 标准文档流下,垂直方向会出现margin塌陷问题,以值的为准。水平方向不会出现
- 浮动的盒子之前不会出现垂直方向的margin塌陷情况。
-
- margin:0 auto
-
- 使用margin: 0 auto;水平居中盒子必须有width,要有明确width;
- 只有标准流下的盒子 才能使用margin:0 auto;
- margin:0 auto;居中盒子,而不是居中文本;
-
- margin与padding的区别
- margin描述的是盒子与盒子之间的关系。
- padding描述的更像父亲与儿子的关系。
-