gpt4 book ai didi

javascript - 段落在底部淡出

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:39:15 25 4
gpt4 key购买 nike

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

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

我还在这个代码笔中复制了这个问题: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/

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