Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allow scroll but hide scrollbar [duplicate]

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?

like image 363
Suganth G Avatar asked Aug 02 '14 13:08

Suganth G


People also ask

How can I hide scrollbar in iframe but still able to scroll?

1. Set the overflow of the parent div as hidden. 2. Set the overflow of the child div to auto and the width 200% (or anything more than 100%, or more than the width of the parent - so that the scrollbar gets hidden).

How do I hide horizontal scrollbar but still scroll?

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

How do I get rid of the double scroll bar?

The combination of html { overflow:auto; } and . site { overflow-x:hidden; } seems to be causing this. Remove both, if possible. (How to handle the main scrolling is best left to the browser, and not messed with by your own CSS.)


3 Answers

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;
}
like image 65
Joe Mike Avatar answered Oct 17 '22 03:10

Joe Mike


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

like image 33
lostInTheTetons Avatar answered Oct 17 '22 04:10

lostInTheTetons


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.

like image 26
imbondbaby Avatar answered Oct 17 '22 05:10

imbondbaby