hide scrollbar while still able to scroll with mouse/keyboard

Possible Duplicate:
How to disable browser or element scrollbar, but allow scrolling with wheel or arrow keys?

I want to know if it is possible to hide the scrollbar, while scrolling is still enabled with mouse/keyboard.

I tried to use CSS: overflow: hidden; The effect is, scrollbar disabled AND scrolling disabled.


For future reference there is also a solution without jQuery - just have the wrapper div style contain overflow:hidden and use this JavaScript two-liner:

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

See demo or complete HOWTO.

Update : you can use the same principle to create scrollable div without scrollbar: demo.


有一个叫做Scrollable的jQuery插件可以实现你想要的功能。


Not natively, but I suppose you could implement your own scrolling mechanism by using Javascript to capture certain keystrokes and re-position the container element accordingly with CSS. It's going to be ugly, though!

链接地址: http://www.djcxy.com/p/88112.html

上一篇: iFrame隐藏滚动条,但仍然可以用鼠标滚轮滚动

下一篇: 隐藏滚动条,同时仍然可以用鼠标/键盘滚动