Languages

CSS - how to change vertical scrollbar height?

3 points
Asked by:
Aaron1
568

How can I change vertical scrollbar height?

More precisely, I want to change this part:

1 answer
3 points
Answered by:
Aaron1
568

By using CSS you can change only vertical scrollbar width.

Possible solutions:

  1. Custom scrollbar library.
  2. By using some trick you can change scrollbar height with additional content wrapper element. The trick disadvantage is empty space that is appended to the content.

 

Simple example:

// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<head>
  <style>

    .container {
        border: 1px solid silver;
        width: 200px;
        height: 150px;
        overflow: auto;
    }

    .wrapper {
        min-height: 1000px;  /* <----- it affects on vertical scrollbar height */
    }
    
  </style>
</head>
<body>
  <div class="container">
    <div class="wrapper">
      Some text here ...<br />Some text here ...<br />Some text here ...<br />Some text here ...<br />
      Some text here ...<br />Some text here ...<br />Some text here ...<br />Some text here ...<br />
      Some text here ...<br />Some text here ...<br />Some text here ...<br />Some text here ...<br />
    </div>
  </div>
</body>
</html>

 

Complex example:

// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<head>
  <style>

    .container {
        border: 1px solid silver;
        width: 200px;
        height: 150px;
        overflow: auto;
    }

    .wrapper-1 {
        min-height: 500px;   /* <----- it affects on vertical scrollbar height */
    }

    .wrapper-2 {
        min-height: 1000px;  /* <----- it affects on vertical scrollbar height */
    }
    
  </style>
</head>
<body>
  <div class="container">
    <div class="wrapper-1">
      Some text here ...<br />Some text here ...<br />Some text here ...<br />Some text here ...<br />
      Some text here ...<br />Some text here ...<br />Some text here ...<br />Some text here ...<br />
      Some text here ...<br />Some text here ...<br />Some text here ...<br />Some text here ...<br />
    </div>
  </div>
  <div class="container">
    <div class="wrapper-2">
      Some text here ...<br />Some text here ...<br />Some text here ...<br />Some text here ...<br />
      Some text here ...<br />Some text here ...<br />Some text here ...<br />Some text here ...<br />
      Some text here ...<br />Some text here ...<br />Some text here ...<br />Some text here ...<br />
    </div>
  </div>
</body>
</html>

 

See also

  1. CSS - style scrollbars (colors and size) 

0 comments Add comment
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.
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