2013-04-29 223 views
3

这正常工作是我使用的那一刻代码:我使用Chrome浏览CSS背景图像不上Android手机

background: url(myimage.jpg) no-repeat center center fixed; 
background-size:100% 100%!important; 
background-position:0 0!important; 
-webkit-background-size: cover; 
-moz-background-size: cover; 
background-size:cover; 
background-attachment:scroll; 

在Android上。当我向下滚动时,我希望背景图像是静态的。我能以其他方式实现吗?

回答

11

不幸的是,这似乎是谷歌从未修复的错误。

上周我亲自处理了同样的问题,最终放弃寻找解决方案。

The bug submission

为了记录在案,也没有在Safari在iOS更多钞票。

+1

它可能在iOS上。它对我的工作很好。感谢您告诉我有关谷歌错误的信息。 – melbourne 2013-04-29 12:53:53

+0

看到有人设法使用background-attachchament:scroll进行提交的bug提交论坛。这怎么可能? – melbourne 2013-04-29 12:56:54

8

试试这个。经过多次试验和错误后为我工作。

html { 
background-image:url('myimage.jpg'); 
background-position: center center; 
-webkit-background-size: cover; 
-moz-background-size: cover; 
-o-background-size: cover; 
background-size: cover; 
height: 100%; 
overflow: hidden; 
} 

body {   
height:100%; 
overflow: scroll; 
} 
+0

我相信这是背景大小,可以帮助 – 2014-12-15 19:49:03

+0

这对我有效!不,'背景大小'没有帮助...它是'高度'和'溢出'技巧,它... – 2015-06-01 03:46:21

+0

去这个解决方案,这也适用于我后很多领主 – 100rbh 2017-09-06 12:12:51

0

感谢nullptr在错误报告中有修复工作。在使用overflow-y性质类似的帖子#23:如果你想申请的其他元素,而不是body背景图像只是确保父包含overflow-y属性hidden和元素

html, body { 
    height: 100%; 
} 
html { 
    overflow-y: hidden; 
} 
body { 
    overflow-y: scroll; 
} 
body { 
    background: url(myimage.jpg) no-repeat center fixed; 
    background-size: cover; 
} 

scroll