这面旗帜只是有不好的CSS。
background-position
是一个速记, background-position-x
和 background-position-y
.
所以,
banner {
background-position: bottom;
background-position-x: center; /* This is not doing anything, because x became 'center' when it was omitted above. */
background-position-y: center; /* This will override the previously set 'bottom' */
}
正如你所提到的, background-position: center
做同样的工作,因为这两个x和y将'中心'。
没有错,使用的关键词,但是如果你刚开始与CSS,我强烈推荐你获得用以使用的百分比。
(你会感谢我后来当你需要更多的具体定位使用 calc()
.
background: 0% 100%
= background: left bottom
background: 100% 0%
= background: right top
background: 50% 50%
= background: center center
资料来源: https://developer.mozilla.org/en-US/docs/Web/CSS/background-position