Languages
[Edit]
EN

CSS - style scrollbars (colors and size)

3 points
Created by:
Saim-Mccullough
688

In this article, we would like to show you how to set scrollbar colors and size using CSS.

In the below, we present solution that works in the following web browsers:

  1. Webkit based: Chrome, Edge and Safari browsers,
  2. Gecko based: Firefox browser.

Preview:

Scrollbar colors set using CSS.
Scrollbar colors set using CSS.

Notes:

Runnable example:

// ONLINE-RUNNER:browser;

<!DOCTYPE>
<html>
<head>
  <style>
    
    .container {
      	height: 100px;
      	width: 250px;
      	overflow: scroll;
      	scrollbar-width: thin;  /* <-------------- required by Firefox                  */
        scrollbar-color: #ffcd70 #ffeac2;  /* <--- required by Firefox                  */
    }
    
    .container::-webkit-scrollbar {  /* <--------- required by Chrome, Edge and Safari  */
      	width: 12px;  /* <--------------------------------- vertical scrollbar width    */
      	height: 12px;  /* <-------------------------------- horizontal scrollbar height */
    }
    
    .container::-webkit-scrollbar-track {  /* <--- required by Chrome, Edge and Safari  */
      	background: #ffeac2;  
    }
    
    .container::-webkit-scrollbar-thumb {  /* <--- required by Chrome, Edge and Safari  */
        background: #ffea75;  
        border-radius: 20px;
        border: 2px solid #ffcd70;
    }

  </style>
</head>
<body>
  <div class="container">
    <pre>
Some very long text here... Some very long text here...
Some very long text here... Some very long text here...
Some very long text here... Some very long text here...
Some very long text here... Some very long text here...
Some very long text here... Some very long text here...
Some very long text here... Some very long text here...
Some very long text here... Some very long text here...
Some very long text here... Some very long text here...
    </pre>
  </div>
</body>
</html>

 

Alternative titles

  1. CSS - change scroll bar colors
  2. CSS - style scroll bar colors
  3. CSS - set scrollbar styles colors
  4. CSS - set scroll bar colors
  5. CSS - change scrollbar colors
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

CSS

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join