Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scrollable but no scroll bar

Tags:

html

css

How can I let a DOM object such as div be able to scroll with scroll wheel on the mouse or by the arrow keys (like overflow:scroll), but not show the scroll bar (like overflow:hidden)?

like image 465
sawa Avatar asked Feb 13 '12 15:02

sawa


People also ask

How do you scroll down if there is no scroll bar?

Go to Settings / Ease of Access / Display and turn off Automatically hide scroll bars in Windows.

Why is the scroll bar hidden?

Content Volume. Scroll bars can disappear when content is able to fit inside its container. For example, a text area might initially contain much more text than it can display at once. The text area suggests the presence of this excess text by showing scroll bars.

How do I hide horizontal scrollbar but still scroll?

To hide the horizontal scrollbar and prevent horizontal scrolling, use overflow-x: hidden: HTML. CSS.


2 Answers

You could set bind an event listener to scrolldown / scrollup (via the mousewheel event, looking at event.wheelDelta to calc size and directino of scroll) and manually position an absoluteley positioned div inside another fixed height absolutely / relatively positioned div. So on scroll down you decrease the y position of the inner div, and on scroll up you increase the y position.

For arrow keys, just bind a similar function to keydown event checking for the down / up arrow as appropriate.

I made a jsfiddle exampling this technique here: http://jsfiddle.net/wsmithrill/U7ju8/32/

like image 84
Matt Fellows Avatar answered Oct 13 '22 14:10

Matt Fellows


If you want to skip javascript altogether, you can try what I suggested here.

Basically, have a container div that's slightly narrower than your content div. Have the container set to overflow:hidden, but the content div set to overflow:scroll. If the container is narrower, it will hide the scroll bar.

like image 42
chipcullen Avatar answered Oct 13 '22 13:10

chipcullen