如何从尾风CSS中的顶部显示粘性和z指数部分?

发布于 2025-02-04 22:17:04 字数 823 浏览 3 评论 0原文

我想用棍棒和z索引组合实现滚动效果。 (我正在使用tailwind)

当前代码的行为相似,但是第二部分并不能保持底部(不是从顶部元素开始)

我想要实现的是 - 一旦您滚动了屏幕的第一部分顶部,下一节开始从顶部元素移动(在这种情况下“设计协作不应该是额外的作品”文本标题)

“在此处输入图像说明”

这是我如何构造它的代码的片段。

            <div className="bg-blue rounded-b-3xl">
                <div className="sticky bottom-0 z-10">
                    <FirstSection />
                </div>
                <div className="sticky bottom-0 z-[9]">
                    <SecondSection />
                </div>
            </div>

第一部分和第二部分被完全覆盖,因此当我完成滚动第一个部分时,屏幕已经位于第二部分的中间元素(因此我什至看不到第二部分的第一个元素)。

最简单的方法是什么?

I want to implement a scroll effect with a stick and z-index combination. (I am using Tailwind)

The current code behaves similar effect, but the second section does not keep the bottom (does not start from the top element)

What I want to achieve is this - once you scroll the first section top of the screen, next section starts moving from the top element (In this case "Design collaboration shouldn't be extra work" text title)

enter image description here

Here is a snippet of my code how I construct it.

            <div className="bg-blue rounded-b-3xl">
                <div className="sticky bottom-0 z-10">
                    <FirstSection />
                </div>
                <div className="sticky bottom-0 z-[9]">
                    <SecondSection />
                </div>
            </div>

The first and second section are completely covered so when I finish scroll the first section, the screen is already in the middle element of the second section (so I can't even see the first element of the second section).

What is the simplest way to achieve this in Tailwind?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文