gpt4 book ai didi

html - 如何在水平滚动的 div 中创建淡入淡出效果

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

我正在创建一个水平滚动的音乐专辑 div,并希望在 div 的右侧有一个淡入淡出,以帮助传达列表水平滚动。

我几乎破解了它,但不太明白为什么我不能完全按照我想要的方式得到它。

这是一个codepen到目前为止我所拥有的......如果位置设置为 absolute 则淡入淡出(为了示例而为红色)效果很好,但设置为 fixed 时失败 -这正是我需要的。

CodePen link

最佳答案

将淡入淡出附加到 .artist__media 而不是 .content。像这样:

.artist__media {
margin-top: 50px;
position: relative;

&:after {
content: "";
position: absolute;
z-index: 1;
top: 0;
right: 0;
bottom: 15px;
pointer-events: none;
background-image: linear-gradient(to right, rgba(255,255,255,0), red 85%);
width: 15%;
}

.content {
white-space: nowrap;
overflow-x: scroll;
overflow-y: hidden;
position: relative;
}
}

参见 fiddle .这就是你想要的吗?

关于html - 如何在水平滚动的 div 中创建淡入淡出效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47401760/

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