28

I have this CSS:

.div {
    background-color: red;
    position: relative;
    height: 414px;
    overflow: auto;
    width: 902px;
    margin: 0px auto;
}

I tried with overflow-y: hidden;, scrollbar disappear but scroll isn't working. Hope you understand what I want... Also, should I use auto or scroll? With auto I see horizontal bar too.

Here is JSFiddle: http://jsfiddle.net/sp95S/
Thanks!

7
  • 1
    What do you expect to happen? This is the correct behaviour. Commented Dec 7, 2013 at 22:18
  • I want to hide scrollbar without affecting scrolling. Commented Dec 7, 2013 at 22:20
  • How would you scroll the content then?! Commented Dec 7, 2013 at 22:20
  • 1
    @DannyBeckett keyboard arrows or mouse wheel? Commented Dec 7, 2013 at 22:22
  • 2
    You need to use JavaScript in that case. CSS alone cannot do what you're asking. Commented Dec 7, 2013 at 22:23

4 Answers 4

26

Create an inner div: http://jsfiddle.net/sp95S/1/

.div {
    background-color: red;
    position: relative;
    height: 214px;
    overflow: hidden;
    width: 452px;
    margin: 0px auto;
}
#inner{
    width: 100%;
    overflow: auto;
    height: 100%;
    padding-right: 15px;
}
Sign up to request clarification or add additional context in comments.

1 Comment

Very smart answer !
18

If you want to hide the scrollbar, but keep the functionality, you can use:

/* Hide scrollbar for Chrome, Safari and Opera */
.example::-webkit-scrollbar {
  display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
.example {
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

Comments

9

It seems like you want to have the page still scroll without the scrollbar showing.

This has been answered here a couple of times already:

Basically you can use javascript (or jquery, though you don't necessarily need it). On webkit browsers, there is a function to hide the scrollbars:

::-webkit-scrollbar { 
display: none; 
}

but it won't work for firefox or internet explorer or opera.

1 Comment

This might work on Opera, since it now runs Webkit, but I still wouldn't use it, since it won't work on anything other than Webkit.
1

If you want to hide the scroll bar, but maintain scroll you can look into a plugin called slimscroll. The scroll bar is there but it can be configure to be rather un-noticable.

http://rocha.la/jQuery-slimScroll

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.