我有一个绝对定位的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>
Run Code Online (Sandbox Code Playgroud)
这是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;
}
Run Code Online (Sandbox Code Playgroud)
我有一个绝对的孩子被约束到父母的边缘,所以为什么它仍然滚动,我怎么能让它保持不变?