2017-10-10 73 views
0

我正在構建個人網站。但我有一個很大的問題,background-attachment:fixed在移動設備上不起作用。我有4個部分,用bg修正,+ javascript效果。background-attachment:固定不適用於移動設備

最後一節很重要... 有人可以幫我解決這些問題嗎?我會實實在在地炫耀。 該網站是在這裏:my site

.hello 
background-image: url("../img/hello.jpg") 
background-repeat: no-repeat 
background-size: cover 
background-position: center 
background-attachment: fixed 
height: 100vh 
min-height: 600px 
display: flex 
flex-direction: column 
justify-content: center 
align-item: center 
text-align: center 

//對不起我的英文不好,

+0

歡迎來到StackOverflow!爲了讓我們更好地爲您提供幫助,能否請您更新您的問題,以便在** [最小,完整和可驗證的示例]中顯示您的相關代碼(http://stackoverflow.com/help/mcve)** 。如果你能讓我們知道你有什麼** [嘗試到目前爲止](http://meta.stackoverflow.com/questions/261592)**來解決你的問題也是有幫助的。有關詳細信息,請參閱有關** [如何提出良好問題](http://stackoverflow.com/help/how-to-ask)**的幫助文章,然後參加** [網站之旅](http://stackoverflow.com/tour)** –

回答

0

這是對移動不支持的不幸......瀏覽器必須徹底每次滾動的時間重新呈現圖像,並在儘管它看起來像是支持它開始淌出https://css-tricks.com/almanac/properties/b/background-attachment/。此刻得到相當的效果的唯一方法是讓你的背景與位置獨立要素:固定的,就像...

.background{ 
position: fixed; 
background-image: url(image source); 
top: 0; 
left: 0; 
width: 100%; 
height: 100%: 
z-index: 0; 
} 

並滑過它應該有任何一個位置的一切:相對或立場:絕對與Z指數高於0.

相關問題