0

我一直在尝试编辑我网站的主 CSS 文件,以便在您向下滚动时背景图像不会移动。我尝试了多种技术,包括下面列出的技术,但问题是从页面顶部滚动时图像仍然会移动……但是一旦到达图像底部,图像就会再次出现,但是在这一点上,它变得可扩展并且当您继续向下滚动时不会移动(这正是我想要的,但我希望它从页面的最顶部一直可扩展)。只是想知道下面的代码中需要修改什么,或者我是否需要在另一部分中查找可能导致此问题的任何特殊代码?

body { background: url(../img/pic.jpg) center fixed no-repeat; 
height:100%; width:100%;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover; 
padding:0; margin:0; text-align:center}
4

1 回答 1

0
body {
    background: url(../img/pic.jpg) center top no-repeat; 
    height:100%;
    width:100%;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover; 
    padding:0;
    margin:0;
    text-align:center;
    position: fixed;
}
于 2013-04-08T04:30:08.403 回答