Remove HTML Scrollbars But Allow Mousewheel Scrolling

Remove HTML scrollbars but allow mousewheel scrolling

There are Javascript methods, see the thread you duplicated.

A better solution is to set the target div to overflow:scroll, and wrap it inside a second element that is 8px narrower, who's overflow:hidden.

The target element will have a hidden scrollbar. The mousewheel will work, but the scroll bar will not show.

<div style='overflow:hidden; width:200px;'>
<div style='overflow:scroll; width:208px'>
My mousewheel scrollable content here....
</div>
</div>

Note that 8px as the width of the scrollbar is a random number - it's probably a lot more, and it could require per browser CSS.

Still better than JS in my book.

remove scroll-bar yet still have controllable content

You can wrap it inside a second div, which is narrower by the scrollbar size and set that div's overflow to hidden.

HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

</head>

<body>

<div id="wrapper">
<div id="scrollWrap">
<div id="pageleft">
<div id="leftheader"></div>
<a href="javascript:;">
<img src="http://i.imgur.com/4rwe1s.jpg" width="46" height="46" alt="*" style="margin:10px 10px;"/>
</a>
<a href="javascript:;">
<img src="http://i.imgur.com/4rwe1s.jpg" width="46" height="46" alt="*" style="margin:10px 10px;"/>
</a>
<a href="javascript:;">
<img src="http://i.imgur.com/4rwe1s.jpg" width="46" height="46" alt="*" style="margin:10px 10px;"/>
</a>
<a href="javascript:;">
<img src="http://i.imgur.com/4rwe1s.jpg" width="46" height="46" alt="*" style="margin:10px 10px;"/>
</a>
<a href="javascript:;">
<img src="http://i.imgur.com/4rwe1s.jpg" width="46" height="46" alt="*" style="margin:10px 10px;"/>
</a>
<a href="javascript:;">
<img src="http://i.imgur.com/4rwe1s.jpg" width="46" height="46" alt="*" style="margin:10px 10px;"/>
</a>
<a href="javascript:;">
<img src="http://i.imgur.com/4rwe1s.jpg" width="46" height="46" alt="*" style="margin:10px 10px;"/>
</a>
<a href="javascript:;">
<img src="http://i.imgur.com/4rwe1s.jpg" width="46" height="46" alt="*" style="margin:10px 10px;"/>
</a>
<a href="javascript:;">
<img src="http://i.imgur.com/4rwe1s.jpg" width="46" height="46" alt="*" style="margin:10px 10px;"/>
</a>

</div>
</div>
</div>

</body>
</html>

CSS

#wrapper { width:980px;margin:0px auto; }
#scrollWrap { width:220px; height:500px; overflow:hidden; }
#pageleft { float:left;margin:10px 10px;width:228px;height:500px;border:1px solid #313131;overflow:scroll; }

#pageleft > #leftheader { width:228px;height:48px;background-image:url(http://i48.tinypic.com/2ecnjx2.png);border-bottom:1px solid #313131;display:block;position:absolute; }

#pageleft a { width:220px;height:66px;display:block;border-bottom:1px solid #313131;transition: all 400ms linear; }

#pageleft a:hover { background-color:#5ca0d1; }​

http://jsfiddle.net/Sgq4j/3/

Referred to this solution: Remove HTML scrollbars but allow mousewheel scrolling

Remove mouse wheel scrolling

I don't know how important is the content in that div but another solution could be to make your pointer have no effect on div pointer-events:none. More explanations here.

iFrame Hide Scroll bars but still be able to scroll with mouse wheel

This should give you what you need to detect the mouse wheel movement: http://www.adomas.org/javascript-mouse-wheel/

And this should give you what you need to control the scrolling of the page:
http://www.mediacollege.com/internet/javascript/page/scroll.html

Detect mouse wheel, determine the direction, scroll accordingly.

Remove scrollbar but not scrolling functionality

There is a library for jQuery named jscrollpane http://jscrollpane.kelvinluck.com/#examples that can modify very much.

But if you only want to hide the bar, you can also push this scrollbar out of view: http://jsfiddle.net/H27BK/

<div id="content">
<div id="scrollable"> ... ... ... </div>
</div>

with CSS

#content {
position: relative;
width: 200px;
height: 150px;
border: 1px solid black;
overflow: hidden;
}
#scrollable {
height: 150px;
width: 218px; /* #content.width + 18px */
overflow-y: scroll;
}

This all based up on a bar-width of 18 pixel.


So we can do some javascript scrollbar width detection script or simply add another div that we put in front of the scrollable div.

http://jsfiddle.net/uNzEz/

HTML is now:

<div id="content">
<div id="scrollable">
<div id="txt"> ... ... ...
</div></div></div>

with CSS like:

#content {
position: relative;
width: 200px;
height: 150px;
border: 1px solid black;
overflow: hidden;
}
#scrollable {
height: 150px;
width: 240px; /* the bar-width can be theoretical 240px - 200px = 40px */
overflow-y: scroll;
}
#txt {
width: 200px;
}

overflow-y: hidden but should enable mouse scrolling

I assume you're wanting to achieve this without JS?

If that's the case, one approach is to hide the scrollbar by offsetting it outside of a parent/wrapper element. So for example:

HTML:

<div class="wrapper">
<div class="child">
<p>Your content</p>
</div>
</div>

CSS:

.wrapper{
height:200px;
width: 100px;
overflow: hidden;
}

.child{
width: 100%;
box-sizing: content-box;
padding-right: 25px; //This amount will differ depending on browser. It represents the width of the scrollbar
overflow-y: scroll;

}


Related Topics



Leave a reply



Submit