Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Styling scroll bars with CSS [duplicate]

Tags:

css

scrollbar

I tried searching online but I didn't find any good sources on this. Is there a way to style scroll bars with pure CSS so that it is compatible with a maximum number of browsers?

like image 531
user773804 Avatar asked May 30 '11 01:05

user773804


People also ask

Can you style the scroll bar CSS?

In September 2018, W3C CSS Scrollbars defined specifications for customizing the appearance of scrollbars with CSS. As of 2020, 96% of internet users are running browsers that support CSS scrollbar styling. However, you will need to write two sets of CSS rules to cover Blink and WebKit and also Firefox browsers.

How do I fix the scroll bar in CSS?

The easy fix is to use width: 100% instead. Percentages don't include the width of the scrollbar, so will automatically fit. If you can't do that, or you're setting the width on another element, add overflow-x: hidden or overflow: hidden to the surrounding element to prevent the scrollbar.

How do I style a horizontal scrollbar in CSS?

::-webkit-scrollbar-button This means it will apply the styling for both the horizontal and vertical scrollbar buttons. To apply specific styling for specific buttons here's what you need to use: ::-webkit-scrollbar-button:vertical:start : This is for the up button in the vertical scrollbar.

How do I customize my browser scroll bar?

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.


1 Answers

You can style scrollbars in Internet Explorer and Webkit only.

Note that these are not standard properties.

However, you can achieve this with JavaScript. One project that does this is jScrollPane.

like image 57
alex Avatar answered Sep 29 '22 22:09

alex