我还在这个代码笔中复制了这个问题:https://codepen.io/bij0520/pen/XoQpEW有什么办法可以让淡出效果一直停留在div的底部吗?谢谢。
.container{
position:relative;
width:300px;
max-height:100px;
overflow-y:scroll;
}
.container:after{
content:"";
position:absolute;
z-index:1;
bottom:0;
pointer-events: none;
background-image: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255, 1) 90%);
width: 100%;
height: 4rem;
}
<div class="container">
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</div>
最佳答案
我对样式表做了一点改动。你想要 p 滚动,而不是容器。
.container{
position:relative;
width:300px;
max-height:100px;
}
.container p {
overflow-y:scroll;
max-height:100px;
}
.container:after{
content:"";
position:absolute;
z-index:1;
bottom:0;
pointer-events: none;
background-image: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255, 1) 90%);
width: 100%;
height: 4rem;
}
<div class="container">
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</div>
关于javascript - 段落在底部淡出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54220452/