"overflow: hidden" on "body" creates a buggy scrollbar with a USB mouse
I am creating a web app and testing with Google Chrome. I have a sidebar item where if I hover over that item I want to disable scrolling for the item body
.
I achieved this by setting overflow: hidden
in a tag body
using CSS whenever the user hovers over the sidebar. I tested this in a browser without connecting a USB mouse and it worked fine:
Sidebar closed ( body
visible scrollbar)
Sidebar Open - Bad ( body
scrollbar still visible, creating an ugly overlap)
Sidebar open - good (my fix: hide body
the scrollbar so that the sidebar scrollbar is shown separately)
This works because Google Chrome does not display scrollbars as actual items (having a width). However, when I plug in a USB mouse, the scrollbars are now wide. And thus, when I move my mouse from outside the scrollbar to the inside of the scrollbar, the width suddenly changes:
Before hover ( body
visible scroll bar)
After Hover - Bad ( body
hidden scrollbar, suddenly reducing the width of the entire sidebar)
This creates a really ugly and glitchy visual effect where the width of the elements changes when you hover over them. I've looked everywhere for a solution for this ... any help would be greatly appreciated! Many thanks!
source to share
If you're on a mac, chances are your OS adds a scrollbar when you plug in your mouse, a scrollbar that will override most CSS selectors.
There is no way to override this with the CSS I am aware of. If you change your system settings, you will find that your site behaves as you intended.
System Settings → General → Show Scroll Bars → Change from [ALWAYS] to [WHEN TO VIEW]
source to share
Pointing width
to the body element will maintain a constant content width.
Here's a working example: https://jsfiddle.net/fuhacLtn/2/
source to share
First, you should pay attention to rendering with other browsers and chrome windows. As you know, the scrollbar of windows is clearly not the same and does not appear the same. You may have surprises.
If not, you might want to check out the jQuery custom croller plugins .
This can help you control the scrolling a little more and overflow
and tweak the scrollbar depending on the render you would like to give it ..
Good luck '
source to share