Customize scrollbar code example

Example 1: custom scroll bar

/* width */
*::-webkit-scrollbar {
  width: 10px;
}

/* Track */
*::-webkit-scrollbar-track {
  background: #f1f1f1; 
}
 
/* Handle */
*::-webkit-scrollbar-thumb {
  background: #888; 
}

/* Handle on hover */
*::-webkit-scrollbar-thumb:hover {
  background: #555; 
}

Example 2: customize scrollbar css

// scroll bar
/* width */
::-webkit-scrollbar {
  background-color: hsl(235, 24%, 19%);
  width: 8px;
}

/* Track */
::-webkit-scrollbar-track {
  background-color: hsla(235, 21%, 11%, 0.322);
  box-shadow: 0 0 3px hsl(235, 21%, 11%);
  border-radius: 10px;
}

/* Handle */
::-webkit-scrollbar-thumb {
  background-color: hsl(235, 21%, 11%);
  border-radius: 10px;
}

/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
  background: hsl(220, 98%, 61%);
}

Example 3: Customize scrollbar

body::-webkit-scrollbar {
  width: 12px;               /* width of the entire scrollbar */
}
body::-webkit-scrollbar-track {
  background: orange;        /* color of the tracking area */
}
body::-webkit-scrollbar-thumb {
  background-color: blue;    /* color of the scroll thumb */
  border-radius: 20px;       /* roundness of the scroll thumb */
  border: 3px solid orange;  /* creates padding around scroll thumb */
}

Tags:

Misc Example