使用 CSS 或 JavaScript 禁用 Safari 5 的“过度滚动”行为
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8826281/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Disable Safari 5's “overscroll” behaviour using CSS or JavaScript
提问by conmulligan
Safari 5 on OS X Lion allows you to scroll past the visible bounds of the page, revealing a linen texture beneath it. It's a nice effect, but for some web apps – particularly those with fixed-position elements like a sidebar – it can be distracting. Does anyone know how to disable the effect using CSS or JavaScript? It must be possible, because some sites like Apple's own iCloudhave done so.
OS X Lion 上的 Safari 5 允许您滚动页面的可见边界,显示其下方的亚麻质地。这是一个不错的效果,但对于某些 Web 应用程序——尤其是那些带有固定位置元素(如侧边栏)的应用程序——它可能会分散注意力。有谁知道如何使用 CSS 或 JavaScript 禁用该效果?这一定是可能的,因为像 Apple 自己的iCloud这样的一些网站已经这样做了。
采纳答案by Charles Sprayberry
There is a blog postthat talks about what you need to do to disable elastic scrolling on both Mac OS X and iOS devices. According to the site it appears to be as simple as the following CSS rule for desktop browsers:
有一篇博客文章讨论了在 Mac OS X 和 iOS 设备上禁用弹性滚动所需的操作。根据该站点,它似乎与桌面浏览器的以下 CSS 规则一样简单:
body { overflow: hidden; }
回答by Bramus
This does the trick:
这可以解决问题:
body,
html {
position: fixed;
}
Tested and verified with iOS8, and iOS9.
在 iOS8 和 iOS9 上测试和验证。
回答by erkfox
html { overflow: hidden;}
body { overflow: scroll;}