我想放大我的背景圖片。我爲這個問題做了一個div,並將其設置爲z-index -1
。它需要有position:absolute
以便其他部分和動畫在頁面上正常工作。 現在唯一發生的事情是,當圖像被放大時,會在底部創建一個水平滾動條。我怎樣才能擺脫這一點,我已經嘗試過溢出:hidden和overflow-x:hidden並將其設置爲diplay:block並顯示:inline-block,因爲我看到它是在SO上建議的,但它沒有工作。CSS - 在使用關鍵幀動畫時隱藏x軸上的滾動條
這是該分區的CSS:
#bg {
background-image: url('/img/cover.png');
background-size: cover;
display: inline-block;
z-index: -1;
animation: zoom 10s;
height: 100vh;
width: 100vw;
animation: zoom 10s;
position: absolute;
overflow: hidden;
overflow-x: hidden;
}
@keyframes zoom {
0% { transform:scale(1,1); }
100% { transform:scale(1.1,1.1);}
}
和HTML:
<div id="app">
<div id="bg">
</div>
<div id="main-section">
</div>
</div>
<div id="drawer">
<div id="magazine-detail">
</div>
<div id="magazine-detail-carousel">
</div>
</div>
<div class="large-10 large-centered columns content">
</div>
</div>
更新
我刪除水平滾動條完全被設置:
html, body {
...
overflow-x: hidden;
}