Javascript 在div中隐藏滚动条

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4963219/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 14:59:01  来源:igfitidea点击:

Hiding a scrollbar in a div

javascriptcss

提问by CamelCamelCamel

Is there a way using css to hide a scrollbar while still keeping its functionality? Even make it transparent or the same color of the background will be fine. Do I have to do this in JavaScript?

有没有办法使用 css 隐藏滚动条,同时仍然保持其功能?甚至让它透明或与背景颜色相同就可以了。我必须在 JavaScript 中执行此操作吗?

回答by Myles Gray

.className {
  overflow: auto;
  overflow-y: hidden;
}

The user will have to scroll using the mouse wheel I believe

我相信用户将不得不使用鼠标滚轮滚动

Compatible with IE too...

也兼容IE...

回答by scragz

<div style="width: 500px; height: 500px; overflow: hidden;"></div>

<div style="width: 500px; height: 500px; overflow: hidden;"></div>

Source: http://www.w3schools.com/css/pr_pos_overflow.asp

来源:http: //www.w3schools.com/css/pr_pos_overflow.asp