我有一個絕對定位div與兩個孩子 - 一個絕對定位的div和靜態div將在父母的內部滾動。它看起來像這樣:絕對定位的div div滾動內絕對定位的父
<div class='frame'>
<div class='absolute-contents'>This should stay put.</div>
<div class='static-contents'>This should scroll under it.</div>
</div>
而這裏的CSS:
.frame {
position: absolute;
top: 40px;
left: 40px;
right: 40px;
bottom: 40px;
overflow-y: scroll;
}
.absolute-contents {
position: absolute;
top: 40px;
left: 40px;
right: 40px;
bottom: 40px;
z-index: 9999;
opacity: .9;
padding: 40px;
}
.static-contents {
margin: 24px auto;
width: 400px;
height: 3000px;
padding: 40px;
}
我不得不受限於母公司的邊緣絕對的孩子,所以爲何仍滾動,我怎樣才能使它保持放?
例子:https://codepen.io/anon/pen/wqZxXG
你試過'的位置是:固定;'了嗎? –
是的。但是我想讓它在父窗口內而不是整個窗口內修復。 –