【发布时间】:2017-08-10 22:07:40
【问题描述】:
我想用伪元素覆盖覆盖具有动态滚动内容的 div。
我遇到的问题是覆盖滚动内容,使折叠下方的任何内容都裸露。
如何让叠加层在其下方的内容滚动时保持原位?
.wantOverlay {
width: 200px;
height: 100px;
overflow-y: scroll;
position: relative;
}
.wantOverlay::after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(150, 150, 150, .45);
}
<div class="wantOverlay">
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean sed est vel ante faucibus tempor nec id.</div>
<div>Unfortunately any text past this point no longer has the overlay.</div>
<div>This text no longer has the overlay.</div>
</div>
【问题讨论】:
标签: css pseudo-element