2013-07-01 214 views
1

我已经在我的网站上设置了一个固定的背景图片,它在台式机和桌面上的所有浏览器上看起来都很好,但在Android手机上它会平铺并重复播放它。我找不到这方面的工作。这里的代码..如果有人有一个固定的背景图像,而不需要在Android Chrome上重复,请让我知道..谢谢。请排除任何无助的评论。CSS设置固定在Android手机上的背景图片?

的CSS:

html, body { 
    height: 100%; 
    margin: 0; 
    overflow-x: hidden; 
    overflow-y: auto; 
    padding: 0; 
    width: 100%; 
    background-image: url("images/320htmlbackground.png"); 
    background-attachment: fixed;  
} 

也试过,但没有奏效.........

html { 
    background: url("images/320htmlbackground.png") no-repeat center center fixed; 
    -webkit-background-size: cover; 
    -moz-background-size: cover; 
    -o-background-size: cover; 
    background-size: cover; 
} 

回答

1

试试这个:

html, body { 
    height: 100%; 
    margin: 0; 
    overflow-x: hidden; 
    overflow-y: auto; 
    padding: 0; 
    width: 100%; 
    background-image: url("images/320htmlbackground.png"); 
    background-repeat: no-repeat; 
    background-position: center center; 
    background-attachment: fixed;  
} 
0

我只是有类似的问题,但我不确定它是否相同。我的问题是,背景图像没有像您期望的那样固定在一个图像上。即当我滚动浏览随页面移动的背景图像时。

事实证明,我已经设置了body标签的背景。除了我的手机之外,它在所有浏览器上运行良好。我将背景更改为html标签,并且它保持在它应该移动的位置,而不会像滚动一样移动。