核心提示:margin: auto;position: absolute;top:0; left:0; bottom: 0; right: 0;这个方法是把margin设为auto,正常情况margin是0。当...
margin: auto;
position: absolute;
top:0; left:0; bottom: 0; right: 0;
这个方法是把margin设为auto,正常情况margin是0。
当绝对定位时,为了满足l,r,b,t都为0,margin被拉伸而且上下左右相等所以居中。
当l=0被取消时,container直接位置右移就能满足r=0,并不需要拉伸margin,所以左右margin默认为0。