Ways to conceal scrollbar track

Is there a method to conceal the track of the scrollbar while keeping the thumb visible? The desired appearance is shown in the following image:

https://i.sstatic.net/6TqmM.png

However, the current view is as follows:

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

The CSS code responsible for styling the scrollbar is given below:

*::-webkit-scrollbar {
    width: 10px;
}
* {
    scrollbar-width: thin;
    scrollbar-color: var(--dark-blue) var(--custom-white);
}
*::-webkit-scrollbar-track {
    background-color: var(--custom-white);
}
*::-webkit-scrollbar-thumb {
    background-color: var(--dark-blue) ;
    border-radius: 20px;
    border: 3px solid var(--custom-white);
}

The revised and finalized CSS code to achieve the desired effect is provided below:

*::-webkit-scrollbar {
  background-color: transparent;
  width: 15px;
}
*::-webkit-scrollbar-track {
  background-color: transparent;
}
*::-webkit-scrollbar-thumb {
  border-radius: 20px;
  border: 4px solid transparent;
  background-color: rgba(0,0,0,0.2);
  background-clip: content-box;
}

Answer №1

If you're looking to have the scrollbar on top of your content, try adding overflow: overlay; to the body tag instead of using overflow: auto. This will give you the desired effect where the scrollbar is layered over the content. I personally found this solution to be effective.

Answer №2

The accepted answer is no longer accurate and was actually misleading even a year ago when it was originally posted.

It's important to note that the "overlay" property was never officially part of the CSS specification. It was only supported by the Webkit engine, but has since been deprecated and removed. Currently, using overflow: overlay behaves like auto, so it should not be relied upon or used in modern web development.

As indicated on Can I Use, current browser support for this feature is only at 8% and is expected to decrease further.

A more accurate response now would be that achieving this desired effect purely with CSS is not possible due to the lack of properties like overflow or webkit-scrollbar. If such functionality is needed, JavaScript must be utilized, with options like the Simplebar library available as solutions.

Answer №3

If you want to make your scrollbar background transparent in webkit browsers, simply apply the background-color property to ::-webkit-scrollbar and set it to transparent.

::-webkit-scrollbar {
    background-color: transparent;
    width: 10px;
}
* {
    scrollbar-width: thin;
    scrollbar-color: var(--dark-blue) var(--custom-white);
}
*::-webkit-scrollbar-track {
    background-color: var(--custom-white);
}
*::-webkit-scrollbar-thumb {
    background-color: var(--dark-blue) ;
    border-radius: 20px;
    border: 3px solid var(--custom-white);
}

Answer №4

After attempting various CSS solutions without success, I decided to turn to an external package for assistance. Thanks to a simple library I found, achieving the desired result became incredibly easy.

The library I used was extremely user-friendly and straightforward to set up. By following the provided example in the wiki, even beginners can easily customize and implement it with ease.

Answer №5

*::-webkit-scrollbar {
    border: none;
    background-color: transparent;
 } /* custom styling for webkit browsers */

*{
    scrollbar-color: #404040b3 transparent; /*custom styling for firefox*/
 }

After much trial and error, this solution was the one that ultimately worked for me.

Answer №6

simple solution:

*::-webkit-scrollbar-track {
    visibility: hidden;
    background-color: var(--custom-white);
}

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

Include an iframe with hidden overflow specifically for Safari browsers

I have a situation where I'm using a third-party iframe to display specific content. The iframe is enclosed within a div container that has border-radius and overflow: hidden properties applied. Strangely, the content inside the iframe doesn't se ...

Processing dates with NestJS

I am trying to format a date string in my NestJS API from 'YYYY-mm-dd' to 'dd-mm-YYYY', or even better, into a date object. Unfortunately, the NestJS framework does not seem to recognize when Angular sends a Date as well. Should I be se ...

What is the best way to add a class to the initial HTML element in my specific scenario?

Currently utilizing the angular framework in my application. Desire to assign a specific class to only the initial element within my ng-repeat iteration. <div class='initialOnly' ng-repeat = 'task in tasks'>{{task.chore}}</di ...

Get names with specific characteristics by using a Javascript object that acts as an associative array

Can someone help me with my code? I'm trying to create an input box that, when I type in "A", will display the names of students who have earned "A" grades. I feel like I'm close to getting it right, but there's something missing. Any assist ...

Text starting to overflow in HTML line before being hidden by right-aligned content

Text is confined to a fixed-width container with hidden overflow. Three status icons may appear on the right side of the container, and I want to prevent text from flowing under these icons without using JavaScript. How can I achieve this with CSS? Below ...

Canvas - Occasionally, using lineTo() can result in crisp edges in the drawing

I've created a simple Canvas drawing app. However, I've noticed that occasionally the lineTo() command generates a line with fewer coordinates, resulting in many edges: I'm currently using the latest version of Firefox - could this issue be ...

Tips for deleting multiple values from an array in Angular 2

When choosing multiple ion-items from a list, I am looking to eliminate identical items from an array. HTML Code <div class="ion-item optionalItem"> <button class="ion-button" ion-item *ngFor="let configop of interiorOption" (click)="itemSel ...

Maintain the menu item color even after clicking

Here is the menu code snippet: <div class="header"> <div id="logo"></div> <ul class="menu"> <li><a href="/index.aspx">Home</a></li> <li><a href="/about.aspx"& ...

Solid colored fill for the active item in the Bootstrap navbar

As I work on constructing a web page using Bootstrap 5 with a fixed top navbar, I am aiming to have the "active" item highlighted with a solid background color similar to the example shown here. Upon inspecting the page using developer tools, I noticed th ...

Angular CLI - Unable to open new project in browser

When I tried to launch a brand new project using Angular CLI by issuing the command NPM start, the application failed to open in the browser. Here is the error logged: 0 info it worked if it ends with ok 1 verbose cli [ 'C:\\Program Files&b ...

I am interested in setting the background for blogger headings H2, H3, and H4 to match the size

view the image hereI am using Blogger and have implemented CSS for H2, H3, and H4 tags with custom background and text size styles. However, I am facing an issue where I want the background size to automatically adjust according to the text size instead of ...

When using Owl Carousel in Chrome, the carousel unexpectedly stops after switching tabs

Hi there, I'm currently testing out the auto play feature in owl carousel. One issue I've encountered is that when I switch to another tab in Chrome and then return to my webpage with the carousel, it stops functioning unless I manually drag the ...

The phrase "something<sup>something</sup>" is showing up as plain text and is not functioning as intended

Currently, I am faced with an issue involving the use of griddle.js and Handsontable in my React application. The problem lies in attempting to display a value with the sup tag. Unfortunately, instead of displaying properly, the output appears as plain tex ...

Retrieving data from a div container on an active website

Imagine having a website similar to , where you want to automatically retrieve the time value every second and save it in a .txt file. Initially, I considered using OCR (optical character recognition) software for this task, but soon realized that relying ...

What is the best way to execute methods once subscription data is received?

Exploring the most effective way to execute multiple methods when new data arrives from an Observable, such as an HTTP request, and those methods need to be called with the data. I have been experimenting with two different approaches, but I find drawback ...

What is the best way to attach a function to an href attribute for creating a dynamic link?

I've been struggling to pass a function to the href attribute in my link tag, but no matter what I try, it just doesn't seem to work. It either redirects to a 404 page or is completely unclickable. What could be causing this issue? This link app ...

Leveraging ngx-treeview in Angular 16 for dynamic tree visual

Currently facing an issue with migrating Angular from version 12 to 16, specifically in regards to the ngx-treeview package. Although the last update was targeted for version 10, it previously worked with version 12 but is now non-functional. The error mes ...

Tips for successfully passing ExpressJS locals variable to an EJS template and utilizing it as a parameter when invoking a JavaScript function during the onload HTML event

const hostname = "192.168.8.154"; const port = 3002; app.use('*', function (req, res, next) { db.collection('sys_params').find().toArray() .then(sysParams => { //console.log(sysParams); app.locals.sysParams ...

Why is the HTC Desire HD unable to detect the (-webkit-min-device-pixel-ratio: 2) media query?

During my testing of mobile web apps, I have observed that the screen images on the htc desire hd appear blurred, which suggests that the pixel ratio for this screen is 2, the same as the iPhone 4. To address this issue for the iPhone 4, I have included al ...

What is the best way to show HTML code on a REACT website without disrupting the existing styles?

I am trying to showcase the following code in a REACT webpage, but it is not displaying as code. Instead, it is showing as actual elements. How can I display the button codes below as actual code? <code> <pre> <Button className='btn-grv ...