2012-08-06 62 views
0

當前正在建立一個新的博客,並在ipad上有一個固定的封面背景問題 - 在瀏覽器上正常工作,但在iPad上滾動,嘗試了很多事情,包括創建一個單獨的背景div與位置:固定的z-index:-1;這產生了相同的效果。修復了ipad背景問題(iOS5)

我不確定爲什麼會發生這種情況,因爲我認爲position:fixed和background-attachment:fixed是爲了在iOS5中排序嗎?

你可以在這裏查看:http://reactionproductions.com/tumblr/

回答

0

你可以嘗試通過

@media screen and (min-width: 1023px){ 
body { 
    background: cover;/*etc*/ 
    width: 100%; 
    height: 100%; 
    position: absolute; 
    } 
} 

在CSS選擇和玩耍。你也可以添加

@media screen and landscape and (min-width: 1023px) 

和肖像,以及取得好ipad設備。 希望它有幫助。

+0

之前已經嘗試用這種只有結果,我可以得到爲背景,以涵蓋的內容包括滾動整個100%(使拉伸喜歡4000px高)。有什麼奇怪的是,我的左側面板(標誌/說明)的位置也是固定的,並且可以繼續在iPad – 2012-08-06 23:42:25

+0

上滾動,您可以嘗試:background-repeat:no-repeat;背景尺寸:含有;.也可以使用safari -webkit-background-clip:padding-box;我可以想到的另一個解決方案是創建一個div wuith標題寬度,以及其他具有左側菜單寬度和高度的div以及一個包含內容寬度和高度的div以及放置在內容中,並使用scroll-y滾動它,以便效果div(header,leftmenu,content)將像固定一樣...只是拋出想法,希望找到解決方案, – 2012-08-07 07:58:31

0

後尋找解決方案,這裏天:http://ryanfait.com/resources/fixed-positioning-in-internet-explorer/

這是怎麼對我的作品:

* { 
    margin: 0; 
} 
html, body { 

    height: 100%; 
    overflow: auto; 
    overflow-y: scroll !important; 
} 
#background_wrap { 
    background: #000000 url(xxxxx.jpg); no-repeat center center fixed; 
    -webkit-background-size: cover; 
    -moz-background-size: cover; 
    -o-background-size: cover; 
    background-size: cover; 
    background-position: center; 
    -webkit-overflow-scrolling: touch !important; 
    z-index: 0; 
    position: relative; 
    width: 100%; 
    height: 100%; 
    overflow: auto; 
} 

#page { 
    -webkit-backface-visibility: hidden; 

} 
.box { 
    position: fixed; 
    left: 10px; 
    top: 180px; 
} 
* html .box { 
    position: absolute; 
} 
0

您是否嘗試過這個解決方案?把它放在窗口的onScroll事件處理程序:

if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod') 
{ 
    //set background fixed with javascript 
    var element = document.getElementById('background'); 
    element.style.webkitTransform = "translate3d(0, " + window.pageYOffset + "px, 0)"; 
};