1

I have a section of text that I want to always show the vertical scrollbar handle even before the user has scrolled. I've read the answer is

html {
    overflow: -moz-scrollbars-vertical; 
    overflow-y: scroll;
} 

However that does not seem to initially show the scroll bar. It only shows it once the user has started scrolling. How would I show it always regardless if they have started scrolling or not? Is this possible?

Thanks!

JS fiddle for example of it not showing before scroll:

https://jsfiddle.net/5k59dxjy/

AndrewLeonardi
  • 3,351
  • 9
  • 47
  • 100

1 Answers1

1

The behavior works as expected on Windows machines, but it appears MacOS and iOS have their own handling of scrollbars. You can see this issue addressed in this question.

Some of the options listed within the answer are to style the scrollbar manually like so:

.frame::-webkit-scrollbar {
    -webkit-appearance: none;
}

.frame::-webkit-scrollbar:vertical {
    width: 11px;
}

.frame::-webkit-scrollbar:horizontal {
    height: 11px;
}

.frame::-webkit-scrollbar-thumb {
    border-radius: 8px;
    border: 2px solid white; /* should match background, can't be transparent */
    background-color: rgba(0, 0, 0, .5);
}

.frame::-webkit-scrollbar-track { 
    background-color: #fff; 
    border-radius: 8px; 
} 

You can also use javascript to manually scroll the scrollbar on page load, just a single pixel. Like this:

$('#scrollable-section').scrollTop(1).scrollTop(0);
JD Davis
  • 3,517
  • 4
  • 28
  • 61