2014-03-26 40 views
0

我使用的是1900x1200的圖片作爲我的頁面的背景:背景圖像覆蓋在Android瀏覽器

    body{ 
        background: url(Layout/Ball7.png); 
        background-position: center center; 
        background-repeat:no-repeat; 
       -webkit-background-size: cover; 
       -moz-background-size: cover; 
       -o-background-size: cover; 
        background-size: cover;} 

它涵蓋了臺式機版本和iOS版本的Safari瀏覽器的整個屏幕。 事情是,在Android本地瀏覽器(我嘗試過三種不同的設備),它在屏幕的頂部和底部留下了一個空白區域(大約15%從頂部和底部空白)。 如果我刪除background-position: center center;,屏幕的頂部也會成爲背景的一部分,但頁面底部仍然會有空白(約爲15%)。我也嘗試使用此代碼作爲解決方案:

height:100% width: 100%; 
height: 100%; 
position: fixed; 
top: 0; 
left: 0; 
z-index: 0; 

但沒有任何運氣,屏幕的底部沒有被覆蓋。我在這裏錯過了什麼嗎?我嘗試了很多選擇,但沒有一個完全符合我的需求。

可能的解決方案:我試圖使用一個非常大的圖像(1900x2500),它確實覆蓋了整個屏幕,但這個解決方案是最後的手段,我想堅持我的1900x1200圖像。

感謝有關此事的任何提示。

回答

-2
body { 
    background: url(Layout/Ball7.png) no-repeat top left fixed; 
    -webkit-background-size: cover; 
    -moz-background-size: cover; 
    -o-background-size: cover; 
    background-size: cover; 
    height:100%; 
    margin:0; 
    padding:0; 
} 
+0

這不會設置任何背景,只有當我將第一個html標籤更改爲body標籤時。 – Oranges

+0

我剛剛編輯我的舊回答。這適用於Nexus 5上的Chrome – AndrePliz

+0

感謝您的回覆,在Android本機瀏覽器上使用您的代碼,屏幕底部仍有空白區域(佔整個屏幕的15%)。感謝有關此事的更多信息。 – Oranges