Webkit Scrollbar Width Change

11,160

Solution 1

.class::-webkit-scrollbar{ width :6px; } The above worked for me. I wanted to apply the width only when the class "class" was added to an element.

Solution 2

Works well in Chrome — http://jsfiddle.net/sergdenisov/wqr5zxpk/2/:

div {
    height: 200px;
    background: #f7f6f5;
    overflow-x: hidden;
    overflow-y: auto;
}

    div::-webkit-scrollbar {
        background: #fff;
        width: 15px;
        height: 15px; 
    }

    div::-webkit-scrollbar-thumb {
        background: #c5c5c5;
    }

Solution 3

You can change horizontal and vertical scrollbar width

::-webkit-scrollbar-track
{
  -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
  border-radius: 10px;
  background-color: #F5F5F5;
  overflow-x: auto;
}

::-webkit-scrollbar
{
  width: 6px;
  height: 6px;
  background-color: #F5F5F5;
  overflow-x: auto;
}

::-webkit-scrollbar-thumb
{
  border-radius: 10px;
  -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);
  background-color: #3c8dbc;
  overflow-x: auto;
}
Share:
11,160
Anum Malik
Author by

Anum Malik

Updated on June 04, 2022

Comments

  • Anum Malik
    Anum Malik almost 2 years

    I am trying to change the width of the scrollbar through -webkit-scrollbar property but Chrome rejects it saying that it is an unknown property. Any idea why ?