小编典典

隐藏滚动条,同时仍然可以使用鼠标/键盘滚动

css

我想知道是否有可能隐藏滚动条,而仍然使用鼠标/键盘启用滚动。

我试图使用CSS: overflow: hidden;。效果是禁用滚动条 禁用滚动。


阅读 296

收藏
2020-05-16

共1个答案

小编典典

供将来参考,还有一个不带jQuery的解决方案-仅使包装div样式包含overflow:hidden并使用以下JavaScript两行代码:

// get the width of the textarea minus scrollbar
var textareaWidth = document.getElementById("textarea").scrollWidth;

// width of our wrapper equals width of the inner part of the textarea
document.getElementById("wrapper").style.width = textareaWidth + "px";
2020-05-16