2013-07-27 61 views
0

我正在建立一個網站,其頭部元素具有固定的全屏幕背景圖像。它完全按照預期工作,除了在移動設備上。我的iphone/ipad上的Safari和Chrome都沒有正確顯示它 - 它似乎縮放到比標題元素大得多的尺寸。在移動設備上破碎的CSS背景大小

下面是完整的網站:http://www.loganmerriam.com/

和有關CSS:

header { 
    background: url(../img/bg.jpg) no-repeat center center fixed; 
    -webkit-background-size: 100% auto; 
    -moz-background-size: 100% auto; 
    -o-background-size: 100% auto; 
    background-size: 100% auto; 
    -webkit-background-size: cover; 
    -moz-background-size: cover; 
    -o-background-size: cover; 
    background-size: cover; 
} 

即使當我使用媒體查詢來加載一個更小的背景下仍然只顯示圖像的一個微小的,縮放後的部分。

也可以任何人指導我一個很好的方式來檢查CSS的idevices?

+0

我使用http://ami.responsivedesign.is/看您的網站,它看起來還好... –

+0

這並不是說是導致它的設備問題的尺寸。我可以縮小桌面瀏覽器的大小,並且背景可以正常工作,這是觸摸瀏覽器有問題。 –

+1

我認爲這與定位有關。 –

回答

1

這是因爲你的風格正在被覆蓋。取下background-size: cover;

header { 
    background: url(../img/bg.jpg) no-repeat center center fixed; 
    -webkit-background-size: 100% auto; 
    -moz-background-size: 100% auto; 
    -o-background-size: 100% auto; 
    background-size: 100% auto; 
    -webkit-background-size: cover; // remove this 
    -moz-background-size: cover; // remove this 
    -o-background-size: cover; // remove this 
    background-size: cover; // remove this 
} 
+0

試過之前,沒有骰子。無論如何,我希望它們被** cover **覆蓋,當它被支持時,它是理想的解決方案。 –