禁用滚动所有移动设备 [英] Disable scrolling in all mobile devices
问题描述
这听起来应该有它所有的解决方案在互联网上,但我不知道为什么我找不到它。我想禁用移动设备上水平滚动。基本上,努力实现这一点:
This sounds like there should be a solution for it all over the internet, but I am not sure why I cannot find it. I want to disable Horizontal scrolling on mobile devices. Basically trying to achieve this:
body{
overflow-x:hidden // disable horizontal scrolling.
}
这可能是相关信息:我也是在我的头上的标签有这样的,因为我也不希望用户能够放大:
This may be relevant information: I also have this in my head tag, because I also do not wish the user to be able to zoom:
<meta content='width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;' name='viewport' />
<meta name="viewport" content="width=device-width" />
感谢
推荐答案
cgvector答案并没有为我工作,但该做的:
cgvector answer didn't work for me, but this did:
document.body.addEventListener('touchstart', function(e){ e.preventDefault(); });
我不会离开它就是这样,一个更聪明的逻辑是需要选择的时候prevent滚动,但这是一个好的开始。
I wouldn't leave it just like that, a smarter logic is needed to select when to prevent the scrolling, but this is a good start.
从这里措施: <一href="http://stackoverflow.com/questions/2890361/disable-scrolling-in-an-iphone-web-application">Disable滚动在iPhone的Web应用程序?
这篇关于禁用滚动所有移动设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!