【问题标题】:Hide scrollbar for mobile devices while keeping the scroll ability在保持滚动能力的同时隐藏移动设备的滚动条
【发布时间】:2014-09-13 14:18:13
【问题描述】:
【问题讨论】:
标签:
android
html
css
webview
【解决方案1】:
根据您添加的链接,我能够提出更可靠的解决方案。
HTML
<div class="container">
<div class="scroll">
[...lots of text]
</div>
</div>
CSS
body {
margin: 0;
padding: 0;
overflow: hidden;
}
.container,
.scroll {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.container {
overflow: hidden;
}
.scroll {
padding-right: 20px;
right: -20px;
overflow-y: scroll;
}
它的作用:
.container 和 .scroll div 都具有与 body 相同的尺寸(全尺寸),并且由于 body 和 .container 都具有 overflow: hidden,它们将永远不会在任何方向显示滚动条。
.scroll 有一个overflow-y: scroll,所以它可以垂直滚动,但不能水平滚动。滚动条被right: -20px 拉出视图,我添加了相同大小的填充,因此内容将始终很好地适合屏幕。浏览器将不需要让您水平滚动
jsFiddle
在 Android 的 Chrome 和原生浏览器中测试