在所有移动设备中禁用滚动 [英] 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" />
谢谢
推荐答案
html, body {
overflow-x: hidden;
}
body {
position: relative;
}
位置相对很重要,我只是偶然发现了它.没有它就无法工作.
The position relative is important, and i just stumbled about it. Could not make it work without it.
这篇关于在所有移动设备中禁用滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文