gpt4 book ai didi

javascript - 段落淡出底部

转载 作者:行者123 更新时间:2023-11-28 00:28:08 25 4
gpt4 key购买 nike

我正在尝试为段落添加淡出效果,这是我所做的:
1

但是当我向下滚动时,淡入效果不会停留在div的底部:
2

我还在此Codepen中复制了该问题: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/54532891/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com