移动(Android和放大器; IOS)浏览器都忽略溢出隐藏在身体,HTML和容器 [英] Mobile (android & ios) browsers are ignoring overflow hidden on body, html, and container
问题描述
我的网站有一些重叠(收藏夹),我需要prevent页面它们下面的滚动时,他们是开放的。所以我用了一点的jQuery添加溢出:隐藏;
到体
, HTML
, #page
。这适用于桌面浏览器,但手机浏览器罚款似乎并没有遵守规则。
My site has a few overlays (lightboxes) and I need to prevent the page scrolling underneath them when they are open. So I use a bit of jQuery to add overflow: hidden;
to body
, html
, #page
. This works fine on desktop browsers but mobile browsers don't seem to follow the rules.
我的页面结构是:
<html>
...
<body>
<div id="page">
...
</div>
</body>
</html>
我的jQuery的只是把类的三个元素被点击触发时。 jQuery是工作(应用样式)和我没有得到任何错误。
My jQuery just puts the class on the three elements when a trigger is clicked. jQuery is working (applying the style) and I'm not getting any errors.
有一个已知的bug和/或已知的修复?
is there a known bug and/or a known fix?
推荐答案
大致使用了同样的想法,但设置一个类 noscroll
的,而不是直接将造型的元素。
Used roughly the same idea but setting a class of noscroll
instead of applying styling directly to the element.
.noscroll { overflow: hidden; }
这用来工作,如果我没有记错,直到iOS的7。
that used to work, if I remember correctly, up until iOS 7.
做了一些尝试,并似乎这做的伎俩。
Did a bit of experimenting and it seems that this does the trick.
.noscroll { overflow: hidden; position: fixed; }
这篇关于移动(Android和放大器; IOS)浏览器都忽略溢出隐藏在身体,HTML和容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!