2013-04-29 231 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