3 回答

TA貢獻1811條經驗 獲得超5個贊
我最近有一個類似的問題,并且意識到這不是由于background-size:cover而是background-attachment:fixed。
我通過使用針對iPhone的媒體查詢并將background-attachment屬性設置為來解決了該問題scroll。
就我而言:
.cover {
background-size: cover;
background-attachment: fixed;
background-position: center center;
@media (max-width: @iphone-screen) {
background-attachment: scroll;
}
}
編輯:該代碼塊位于LESS中,并為假定了預定義變量@iphone-screen。

TA貢獻1811條經驗 獲得超6個贊
這適用于Android 4.1.2和iOS 6.1.3(iPhone 4)以及臺式機開關。為響應性網站而寫。
以防萬一,在您的HTML頭中,如下所示:
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
HTML:
<div class="html-mobile-background"></div>
CSS:
html {
/* Whatever you want */
}
.html-mobile-background {
position: fixed;
z-index: -1;
top: 0;
left: 0;
width: 100%;
height: 125%; /* To compensate for mobile browser address bar space */
background: url(/images/bg.jpg) no-repeat;
background-size: 100% 100%;
}
@media (min-width: 600px) {
html {
background: url(/images/bg.jpg) no-repeat center center fixed;
background-size: cover;
}
.html-mobile-background {
display: none;
}
}
- 3 回答
- 0 關注
- 540 瀏覽
相關問題推薦
添加回答
舉報