Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Horizontal Scroll on Div

There is a cross browser dilemma especially now that safari uses an internal scroll mechanism that floats on top.

When a div with fixed height's content ends up getting larger than the div we need a scroll bar, but the scrollbar takes out some width and thus a horizontal bar is added to. How do we prevent a horizontal scroll even if the content is to wide I want no ability for the user to be able to scroll horizontally.

The CSS3 property overflow-x:hidden, still allows the user to scroll left and right with a trackpad. I want it disabled completely, or a solution that removes the problem of the vertical scroll bar taking width from the div.

Any ideas?

Marvellous

like image 248
RIK Avatar asked Sep 09 '11 13:09

RIK


People also ask

How do I turn off horizontal scrolling?

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

How do I make a div not scrollable?

On top of this for browser compatibility on the parent element you will need to apply text-align: center; which will apply the needed centering of the element. As for preventing scrolling on the div, all you need to apply on the footer is overflow: hidden; and that should do the trick.

How do I stop scrolling when scrolling a div element CSS?

bind('mousewheel DOMMouseScroll', function() { return false; }); $(this).

How do I stop horizontal scrolling in web design?

You can also set the overflow-x CSS property to hidden, which prevents child content from wrapping within its container but turns off sideways scrolling. Another solution is to set the width of child elements to 100%.


1 Answers

One solution is that you make the vertical scroll bar always display:

overflow-y: scroll

But still the scroll bar's width doesn't stay the same across browsers.

Or you can make a custom scroll bar replacement with div/CSS/JavaScript. Here is a jQuery plugin which seems promising:

http://jscrollpane.kelvinluck.com/

like image 61
qingbo Avatar answered Oct 14 '22 07:10

qingbo