我无法将我的背景居中。不管我把BG改小尺寸让它居中都不会。
她是我的 CSS:
#container {
background-image: url(Photos/BG.png);
background-repeat:no-repeat;
background-position: center center;
height: 1813px;
width: 1024px;
}
它不会使背景居中 - 即使使用较小尺寸的照片,它也会一直位于显示器的左上角。谢谢大家!
最佳答案
要使背景图像居中,您不需要指定 center center 两次。应该是这样的:
#container {
background-image: url(Photos/BG.png);
background-repeat:no-repeat;
background-position: center;
height: 1813px;
}
关于html - CSS 背景位置不会居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40492853/