こんにちは、ページにいくつかの div があり、それらの背景画像を展開して div 全体をカバーし、それを展開してビューポートの幅を埋めることができます。
明らかbackground-size: cover
に、iOS デバイスで予期しない動作をします。修正方法の例をいくつか見てきましたが、私の状況ではそれらを機能させることはできません。理想的には、余分なタグを HTML に追加したくない<img>
のですが、それが唯一の方法である場合は追加します。
これが私のコードです:
.section {
margin: 0 auto;
position: relative;
padding: 0 0 320px 0;
width: 100%;
}
#section1 {
background: url(...) 50% 0 no-repeat fixed;
background-size: cover;
}
#section2 {
background: url(...) 50% 0 no-repeat fixed;
background-size: cover;
}
#section3 {
background: url(...) 50% 0 no-repeat fixed;
background-size: cover;
}
<body>
<div id="section1" class="section">
...
</div>
<div id="section2" class="section">
...
</div>
<div id="section3" class="section">
...
</div>
</body>
問題は、ブラウザの可変幅と div 内のコンテンツの可変高さを考慮して、セクション div を完全に覆うように背景画像を取得するにはどうすればよいかということです。