【问题标题】:hiding scroll bars when using overflow:scroll; but keep scrolling ability [duplicate]使用溢出时隐藏滚动条:滚动;但保持滚动能力[重复]
【发布时间】:2012-08-04 14:36:53
【问题描述】:

可能重复:
hide scrollbar while still able to scroll with mouse/keyboard

我为网络应用制作了一段 UI。它是一个侧边栏,它需要让用户在没有滚动条的情况下滚动它。内容高 500px,但容器高 300px。

我已将容器设置为具有overflow:scroll,但随后出现滚动条(这是我所期望的)。我知道我可以使用overflow:hidden 禁用滚动条,但这也会禁用滚动。

有没有办法让它滚动但禁用滚动条?

【问题讨论】:

    标签: javascript jquery css overflow


    【解决方案1】:

    hide scrollbar while still able to scroll with mouse/keyboard

    // 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";
    

    或者用 jQuery 用鼠标滚轮插件捕捉鼠标滚动:How can I disable a browser or element scrollbar, but still allow scrolling with wheel or arrow keys?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-17
      • 2014-09-25
      • 2011-10-01
      • 2016-11-21
      相关资源
      最近更新 更多