Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I increase a scrollbar's width using CSS?

Is it possible to increase the width of a scrollbar on a <div> element placed inside the <body>?

I am not talking about the default scrollbar on the browser itself, this page runs in full screen mode and because the browser scrollbar never comes into picture, the inner <div> element has its own scrollbar.

like image 451
t0mcat Avatar asked Oct 29 '10 15:10

t0mcat


People also ask

How do I change the scrollbar width in CSS?

The scrollbar-width property is used to set the width or thickness of an element's scrollbar when shown. This property can be used on pages where the user interface requires the element to be displayed more prominently and shrinking the scrollbar width gives more space to the element.

How do I make my scrollbar wider?

How to Customize the Scrollbars Width to be Narrower or Wider. If you want to change the scroll width too (or only the scroll width), you'll find it just under ScrollHeight in the right pane. So double-click/tap on the ScrollWidth to open the Edit String window.

How do I make my scroll bar thinner CSS?

auto is the default value and will render the standard scrollbars for the user agent. thin will tell the user agent to use thinner scrollbars, when applicable. none will hide the scrollbar completely, without affecting the element's scrollability.

How do I get the scrollbar width in CSS?

To get the width of the scrollbar, you use the offsetWidth and clientWidth of the Element : The offsetWidth returns the width of the Element in pixels including the scrollbar. The clientWidth returns the with of the Element in pixels without the scrollbar.


1 Answers

This can be done in WebKit-based browsers (such as Chrome and Safari) with only CSS:

::-webkit-scrollbar {     width: 2em;     height: 2em } ::-webkit-scrollbar-button {     background: #ccc } ::-webkit-scrollbar-track-piece {     background: #888 } ::-webkit-scrollbar-thumb {     background: #eee }​ 

JSFiddle Demo


References:

  • Custom Scrollbars in WebKit | CSS-Tricks
  • WebKit scrollbar demo from CSS-Tricks
  • 15 Different scrollbar configurations
like image 132
uınbɐɥs Avatar answered Oct 07 '22 09:10

uınbɐɥs