本文介绍了“margin:0 auto”之间是否存在任何差异;和“margin:auto”;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我们想要页面的主容器对齐中心时,我们通常使用margin:0 auto;,但是当我使用 ;的行为在某些浏览器中是一样的(Google Chrome,Firefox)。
When we want page's main container align center, we usually use "margin: 0 auto;", but when I use "margin:auto;", behaviour are the same in some browser I have (Google Chrome, Firefox).
推荐答案>是的。
margin: 0 auto;将元素的左右边距设置为 auto ,并将顶部和底部边距设为 0 。
Sets the element's left and right margins to auto, and the top and bottom margins to 0.
margin: auto;将全部边距设置为 code>。由于< body> 的高度为100%,因此垂直 auto 没有效果。
Sets all the margins to auto. You are probably getting the same behaviour due to your <body> being 100% height, hence the vertical auto margins have no effect.
更多推荐
“margin:0 auto”之间是否存在任何差异;和“margin:auto”;
发布评论