2012-07-13 54 views
0

我正在用jQuery Mobile開發一個Asp.Net MVC網站。 我有這個CSS部分設置背景圖像固定在該網站的中心,而滾動:如何模擬背景附件iPad

background: white url(Image/A-HD.jpg); 
background-repeat: no-repeat; 
background-position: 50% 50%; /*or center center */ 
background-attachment: fixed; 
background-size: 50%; 

它的工作原理無處不在,除了爲iPad 2(我測試的只有一個)。好像background-attachment:fixed;無法正常工作:背景圖片實際上停留在中心位置,但不會跟隨我的滾動。

那麼,有沒有辦法模擬background-attachment:fixed;爲iPad2(和類似的,我想)

謝謝!

回答

1

你可以使用一個單獨的元素和position: fixed來解決這個問題!

HTML:

<div id="Background"></div> 

<div id="Content"></div> 

CSS:

#Background { 
    background: white url(Image/A-HD.jpg) no-repeat 50% 50%; 
    background-size: 50%; 
    position: fixed; 
    top: 0; 
    left: 0; 
    right: 0; 
    bottom: 0; 
}