1、元素有时候,就算没有设置width或height,也会自动填充,比如:
div{background:#fafafa}
会默认margin:auto自动填div满容器
2、元素有时候,就算没有设置width或height,也会自动填充对应方式,比如:
div{display:absolute;left:0;right:0;background:#fafafa}
div的宽度自动填充容器.
3、此时,如果设置width或height,自动填充特性就会被覆盖。
div{width:500px;background:#fafafa}
4、原本应该被填充的尺寸被width或height强制变更,而margin:auto就是为了填充这个变更的尺寸设计的
div{width:500px;margin-right:100px;margin-left:auto;background…..}