50

I have a div with element styles like this:

 <div style="overflow-y: auto; max-height: 300px;">< id="DivTableContainer" ></div>

I need to allow scrolling along the y-axis when it becomes higher than 300px, this works fine. But I need to set "visiblity = false" to scroll bar itself.

I tried to use this element style:

overflow-y: hidden;

While it hides the scroll bar, it also disallows scrolling. Is there a way to get scrolling without having the scrollbar visible?

John
  • 1
  • 13
  • 98
  • 177
Suganth G
  • 5,136
  • 3
  • 25
  • 44
  • 1
    Try [nanoScroller](http://jamesflorentino.github.io/nanoScrollerJS/), it shows the scroll bar when you hover. – Mottie Aug 02 '14 at 13:44
  • Hi @Jake745. I edited your question, because it was not comprehensible before. Can you please check that it still asks what you wanted to ask? If not, please leave a comment or edit it yourself :). – Jonas Schäfer Aug 02 '14 at 18:37
  • Good work Jonas. Thanks for your support :) – Suganth G Aug 04 '14 at 04:08

3 Answers3

39

It's better, if you use two div containers in HTML .

As Shown Below:

HTML:

<div id="container1">
    <div id="container2">
        // Content here
    </div>
</div>

CSS:

 #container1{
    height: 100%;
    width: 100%;
    overflow: hidden;
}

 #container2{
    height: 100%;
    width: 100%;
    overflow: auto;
    padding-right: 20px;
}
Joe Mike
  • 1,150
  • 1
  • 9
  • 16
28

I know this is an oldie but here is a quick way to hide the scroll bar with pure CSS.

Just add

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

To your id or class of the div you're using the scroll bar with.

Here is a helpful link Custom Scroll Bar in Webkit

lostInTheTetons
  • 1,162
  • 1
  • 13
  • 23
11

Try this:

HTML:

<div id="container">
    <div id="content">
        // Content here
    </div>
</div>

CSS:

#container{
    height: 100%;
    width: 100%;
    overflow: hidden;
}

#content{
    width: 100%;
    height: 99%;
    overflow: auto;
    padding-right: 15px;
}

html, body{
    height: 99%;
    overflow:hidden;
}

JSFiddle Demo

Tested on FF and Safari.

imbondbaby
  • 6,351
  • 3
  • 21
  • 54