You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

iPhone设备滚动功能失效:其余设备正常,附相关CSS代码

Fixing iPhone Scrolling Failure When Other Devices Work Fine

Hey there, let's figure out why your iPhone's scrolling is broken while every other device works as expected. Looking at your provided CSS, I can spot a couple of key issues that are likely causing this behavior:

Potential Issues in Your Current CSS

  • Fixed height on body: You've set height: 1300px!important on the body element. On iPhones, when a container has a fixed explicit height, it won't expand to fit content that overflows—so even with overflow-y: scroll, the body can't scroll beyond that 1300px mark if your page content is longer.
  • Overused !important flags: These can override default browser behaviors on Safari (iPhone's default browser) and make it harder for the scroll mechanism to work as intended.
  • Combined style conflicts: The position: relative!important paired with fixed height might be throwing off WebKit's scroll detection logic.

Fixed CSS Code

Here's a revised version of your media query that addresses these issues:

@media only screen and (-webkit-min-device-pixel-ratio: 0) {
  @supports (-webkit-overflow-scrolling: touch) {
    html {
      height: 100%;
      overflow-y: auto;
    }
    body {
      overflow-y: scroll;
      -webkit-overflow-scrolling: touch;
      -webkit-text-size-adjust: none;
      min-height: 100vh; /* Let body expand with content instead of fixed height */
      position: relative;
      background-image: radial-gradient(circle at center , #0c505f, #053540 );
      color: #0c505f;
      width: 95%;
    }
  }
}

Key Changes Explained

  • Added styles to html: Ensures the root element has proper height and overflow settings, which helps Safari recognize the scrollable area correctly.
  • Replaced fixed height with min-height: 100vh: This keeps the body at least full viewport height but lets it expand to fit longer content, enabling natural scrolling when content overflows.
  • Removed unnecessary !important: These flags were blocking default browser behaviors—only keep them if you absolutely need to prioritize these rules over other styles.

Additional Checks

If scrolling still doesn't work after this fix, double-check:

  • No parent wrapper elements have overflow: hidden set (this would block scrolling entirely).
  • You're not using JavaScript that hijacks scroll events specifically on iOS (some scroll libraries can conflict with -webkit-overflow-scrolling: touch).

内容的提问来源于stack exchange,提问作者Alina Bayron

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 10:48:42