问题
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).
回答1:
Yes.
margin: 0 auto;
Sets the element's left and right margins to auto
, and the top and bottom margins to 0
.
margin: 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.
来源:https://stackoverflow.com/questions/8312354/is-there-any-difference-between-margin-0-auto-and-margin-auto