当我使用位置粘性ios Safari在手机上时溢出内容错误

发布于 2025-02-09 04:19:23 字数 1351 浏览 0 评论 0原文

我想在截面内使用两个块的位置粘性块(第一个)。第一个粘块是图像,其次是任何具有白色背景的内容。

demo link

html:css:

<section>
  <div class="first">
    <img src="https://images.unsplash.com/photo-1604311795833-25e1d5c128c6?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=654&q=80" alt="asd">
  </div>
  <div class="second">Lorem ipsum dolor sit amet consectetur adipisicing elit. Ex voluptatum sit tempore libero, temporibus ea maxime consequatur pariatur incidunt iste.</div>
</section>

css:

section {
    position: relative;
    display: flex;
    flex-direction: column;
}
.first {
    position: sticky;
    top: 0;
}
img {
    max-width: 100%;
    display: block;
}
.second {
    font-size: 62px;
    z-index: 1;
    background: white;
}

它可以正常工作,但是对于Safari中的iOS设备,我们可以看到我们可以看到的一部分。图像。我们还可以在Safari移动模拟器中检测到它。 screenshot-bug

如果我添加属性溢出:hissed for parent for for parent for for parent for parent section section searve naterve butsion nocation却无法正常工作:sticky无法正常工作。

我们可以为这个问题提供另一个解决方案吗? 先感谢您! 问候

I want to use position sticky block(first) inside the section with two blocks. First sticky block is image and second is any content with white background.

DEMO link

HTML:

<section>
  <div class="first">
    <img src="https://images.unsplash.com/photo-1604311795833-25e1d5c128c6?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=654&q=80" alt="asd">
  </div>
  <div class="second">Lorem ipsum dolor sit amet consectetur adipisicing elit. Ex voluptatum sit tempore libero, temporibus ea maxime consequatur pariatur incidunt iste.</div>
</section>

CSS:

section {
    position: relative;
    display: flex;
    flex-direction: column;
}
.first {
    position: sticky;
    top: 0;
}
img {
    max-width: 100%;
    display: block;
}
.second {
    font-size: 62px;
    z-index: 1;
    background: white;
}

It works properly but for iOS devices in Safari we can see part of image. We also can detect it in a Safari mobile emulator.
screenshot-bug

If I add property overflow: hidden for parent section it will solve issue but position: sticky will not work.

Can we have another solution for this issue?
Thank you in advance!
Regards

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

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

发布评论

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