The vertical slider length in CSS

Is the default height of the scroll thumb determined by the scrollable area? If not, am I able to adjust the scrollbar thumb height myself? If so, how can this be done? I attempted to change it using the following code snippet.

body::-webkit-scrollbar-thumb {
  background-color: darkgrey;
  outline: 1px solid slategrey;
  height: 5px;
}

However, I did not see any changes on the page. Any assistance would be greatly appreciated. Thank you in advance.

Answer №1

It seems that the height of the thumb is determined by the size of content, and although you can adjust the width within the ::-webkit-scrollbar, the height will always remain tied to the content.

::-webkit-scrollbar              { /* 1 */ }
::-webkit-scrollbar-button       { /* 2 */ }
::-webkit-scrollbar-track        { /* 3 */ }
::-webkit-scrollbar-track-piece  { /* 4 */ }
::-webkit-scrollbar-thumb        { /* 5 */ }
::-webkit-scrollbar-corner       { /* 6 */ }
::-webkit-resizer                { /* 7 */ }

https://i.sstatic.net/eUQ9T.png

https://i.sstatic.net/AtWVn.png

Source

Answer №2

To keep the scrollbar thumb at a fixed minimum height even during scrolling, follow this method:

::-webkit-scrollbar-thumb {
    min-height: 60px;
   }

Answer №3

Here's a neat trick you can try:

::-webkit-scrollbar-thumb{
    background-color: transparent;
    border-top: 60px solid green /*or choose any height and color you prefer*/;
}

This approach will set the height at a fixed value of 60px, but keep in mind that it may limit scrolling to the very bottom due to the transparent area.

Answer №4

Don't waste any more time here, I've already spent too much on this trivial matter.

For accessibility purposes, you have limited control over the width and color of a scrollbar's thumb and track, but not its height. The thumb indicates the current position in the scrollable area. It moves along the track as you scroll and is typically draggable.

Refer to the Official Chrome Documentation Read Here

Here's a helpful tip for you, increasing the height of the element with the scrollbar will automatically decrease the height of the scrollbar thumb. Therefore, the scrollbar height depends on the height of the containing element. I hope this adds some value to your day. Have a great day and happy coding!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What steps can be taken to fix the issue of an Undefined Index occurring while using ajax

Trying to set up a dependent combobox using Ajax, but encountering an error (Undefined index: faculty_id). No typos in the code, and the query works fine in SQLyog tests. Here's the Ajax code: $(document).ready(function(){ $('#faculty&apos ...

pressure exerted on the body

Recently, I've been working on a project for the website . One of the main issues I've encountered is that the <body> element is consistently 20px lower than it should be at the top. This has led to visible problems with the background grad ...

Utilizing version 4 of Bootstrap to create a visually appealing full

I am currently using the latest version of bootstrap, but I have encountered an issue with my sidebar being too short and not reaching full height. You can view the problem here: Is this problem caused by my CSS or is it a bootstrap issue? And how can ...

Do plugins necessary for HTML5 Video playback?

I've done my fair share of research, but I'm still feeling a bit puzzled. When it comes to HTML5 compatible browsers (specifically Chrome 20 and Safari for Windows 5.1.7 in this case), if I include video using tags, is the expectation that it wil ...

Prevent the page from scrolling while the lightbox is open

I am struggling with a lightbox that contains a form. Everything is functioning properly, but I need to find a way to prevent the HTML page from scrolling when the lightbox is active. <a href = "javascript:void(0)" onclick=" document.getElementById(& ...

Experiencing difficulties with a JavaScript loading issue where images are not loading properly

I recently downloaded a calendar JavaScript file and placed it in the directory /user/js/calendar. In my HTML file located at /user/, I added the following code: <script language="JavaScript" src="js/calendar/calendar_us.js"></script> <link ...

What steps can I take to resend a fetch request in React.js if I receive a 408 or 503 error?

There are times when I am fetching data from a server and the request takes too long, resulting in the server responding with a 408 status code. This is how my code currently looks: export class ResponseError extends Error { public response: Response; ...

Missing Marker Pin on Google Maps

I am experiencing an unusual problem with the Google Maps widget where the marker is not displaying on my actual website, but it does show up when I test the code in Codepen. Codepen: http://codepen.io/anon/pen/LxLprp <script src="https://maps.google ...

Change the country name to all lowercase letters

I'm attempting to retrieve the country flag icon of the Open Weather Map API. For example: The JSON response for the country code from the API request is in uppercase. To obtain the correct icon for the country, I need the country code in lowercase. ...

Arranging images and text side by side with varying breakpoints using Bootstrap classes

In my layout, I have an image and text side by side, with the image appearing first and the text to its left. My goal is to display the text above the image when the screen size is reduced to a small breakpoint, and then switch back to the original layou ...

Identifying flags that do not actually exist in flag-icon-css library

Please take a moment to review the code snippet provided. I have created a Datatable that contains countries along with their country codes. Within my code, I am generating HTML to display flag icons using the format flag-icon-COUNTRYCODE. However, some ...

Issues with jQuery scroll effect not functioning properly in Firefox due to transformation errors

I've encountered an issue with implementing a scroll effect in Firefox. The code works perfectly fine in Chrome, Safari, and Opera, but for some reason, it's not functioning properly in Firefox. I have carefully reviewed the '-moz-transform& ...

PHPMailer encountered a syntax error while processing the command 'composer install'

Attempting to implement PHPMailer on GoDaddy for the first time, encountering an error message; Parse error: syntax error, unexpected 'install' (T_STRING); when trying to run composer install. I've searched through other resources and tinker ...

How to correct header alignment in HTML for Google Table

Utilizing the google visualization table to generate a html table, I have successfully fixed the top section of the html using the stuckpart div. This ensures that regardless of how I scroll, the button remains in place. However, I now aim to fix the table ...

Tips for inserting an image within two divs within the .row class (leveraging Bootstrap 4)

Take a look at my code snippet: <div class="row"style=""> <div class="panel panel-success col-sm-3" style="background-color: #d16b55; "> <div class="panel-body" style="height: 1000px; margin-left: 50px;overflow: hidden !important;"> ...

How to stop font-family and letter spacing from affecting the margin of div and ul elements in CSS

I'm facing a challenge with aligning a rotated div and an unordered list in a container. Adjusting the margin of either element does the trick, but changing font-family or letter-spacing globally affects the spacing between the two. Check out this JS ...

Struggling to create a SVG Line with DOM Manipulation in Typescript

I'm having trouble adding an SVG element to my div using the appendChild function in TypeScript. I want to add a line inside the SVG, but for some reason, I can't see the line output on my browser. There are no errors showing up either. Please he ...

Incorporate JavaScript code into an event that already exists

How can I enhance an existing JavaScript event by adding a new function to it? <input type="text" value="" maxlength="2048" accesskey="S" title="Rechercher..." id="ctl00_ctl42_g_c33cc49a_f2b3_4d8f_9da7_c43b759a91ea_csr_sbox" autocomplete="off" autocorr ...

Guide to customizing margins at specific breakpoints in Bootstrap 4 without using javascript

Despite exploring numerous solutions and trying them out, I have yet to achieve the desired results. I am looking to customize margins for various breakpoints in Bootstrap. For example: View for laptops, Tablet view The issue may be related to defined w ...

Vue.js - Problem with loading image on screen

Although I have experience with React, I am currently facing the challenge of using Vue for a code assessment for the first time. My struggle lies in creating a reusable image component with WAI-ARIA accessibility. Despite my efforts, I cannot get the imag ...