Disable horizontal scrolling on div

There is a cross-browser problem, especially now when safari uses the internal scroll mechanism that floats on top.

When a div with fixed height content ends, becoming larger than the div, we need a scroll bar, but the scroll bar takes some width, and thus a horizontal bar is added. How to prevent horizontal scrolling, even if the content is wide, I don’t want the user to be able to scroll horizontally.

The CSS3 overflow-x: property is hidden, still allowing the user to scroll left and right using the trackpad. I want it to be completely disabled, or a solution that fixes the problem of vertical scrollbar taking width from div.

Any ideas?

Wonderful

+6
source share
2 answers

One solution is that you always show a vertical scrollbar:

overflow-y: scroll 

But still the width of the scrollbar does not remain unchanged in browsers.

Or you can create your own scrollbar using div / CSS / JavaScript. Here is a jQuery plugin that seems promising:

http://jscrollpane.kelvinluck.com/

+2
source

Set the image as background to fix your problems.

0
source

Source: https://habr.com/ru/post/896985/


All Articles