I'm trying to apply custom styles to the scrollbars (actually, trying to make scrollbars always visible) and preserve the momentum scrolling for the iOS app:
#container { height: 400px; overflow: scroll; -webkit-overflow-scrolling: touch; } #container::-webkit-scrollbar { -webkit-appearance: none; background-color: #000; } #container::-webkit-scrollbar:horizontal { height: 6px; } #container::-webkit-scrollbar-thumb { background-color: #000; } #container::-webkit-scrollbar-track { -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); background-color: #333; }
But -webkit-overflow-scrolling: touch
and ::-webkit-scrollbar
styles don't work together. There's already a related question on StackOverflow:
-webkit-overflow-scrolling: touch breaks my -webkit-scrollbar css in iOS
So, from the height of spring'2016, is there any way to have a momentum scrolling while styling the scrollbars at the same time? I'm ready to ditch the -WebKit-overflow-scrolling: touch
if there's another method that can fake it.
Please don't suggest using niceScroll, iScroll, etc. - I've tried these; actually, I'm currently using one of such scripts and want to get away from it.
Scrollbar Selectors For webkit browsers, you can use the following pseudo elements to customize the browser's scrollbar: ::-webkit-scrollbar the scrollbar. ::-webkit-scrollbar-button the buttons on the scrollbar (arrows pointing upwards and downwards). ::-webkit-scrollbar-thumb the draggable scrolling handle.
Note: ::-webkit-scrollbar is only available in Blink- and WebKit-based browsers (e.g., Chrome, Edge, Opera, Safari, all browsers on iOS, and others). A standardized method of styling scrollbars is available with scrollbar-color and scrollbar-width .
We use pseudo-element (i.e., ::-webkit-scrollbar-thumb ) with -webkit prefix and set scrollbar-thumb background- color . We use box-shadow on scrollbar-track to make it stylish and add contrast between the scrollbar and scrollbar-track.
If you are using Windows PC or you've got a persistent scrollbar visible on Mac then you might see double scrollbars in the Modal Box if the modal content is lengthy and beyond the viewport height. The Modal Box will remain scrollable but the scrollbar will get hidden.
As it was mentioned in the thread linked above, -webkit-overflow-scrolling: touch
is not compatible with your -webkit-scrollbar
properties. If you don't want to download a 3rd party scroller, you will have to write some custom JS to get the functionality you're looking for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With