Tips for customizing scrollbar appearance with CSS

While attempting to create a custom scrollbar, I encountered an issue with the image of the scrollbar not displaying properly when the background color is changed. Specifically, when the background color is dark (such as black), the scrollbar blends in and becomes invisible. Is there a way to obtain a white background image for the scrollbar in base64 format?

Here is my current code: https://jsbin.com/nivepoyoye/edit?html,css,output

<div class="abc pqr" style="background:#000">
    asdasdasdasdasdasdasdasdasdasdasdasdasdas
    sdasd
  </div>
  

I am still facing issues with the scrollbar not displaying correctly.

.pqr::-webkit-scrollbar-thumb {
        background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAALCAIAAADa28u7AAAABnR...
        background-position:0 50%;
        background-repeat:repeat-x;
/*     background-color:#fff
     */ }

    .pqr::-webkit-scrollbar {
        height: 18px;
    }

Could someone guide me on where to find a white scrollbar image in base64 format so that it enhances the overall look of the scrollbar?

Answer №1

Does this meet your requirements?

* {
  scrollbar-width: thin;
  scrollbar-color: red green;
}

/* This code is compatible with Chrome, Edge, and Safari */
*::-webkit-scrollbar {
  width: 12px;
}

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

Modify the standard width setting in my css file

I'm looking to adjust my default width in the CSS file so I can incorporate an HTML5 animation on my website. Here's what I've placed on the site: <div id="nakuru_hype_container" style="margin:auto;position:relative;width:100%;height:33 ...

Not motivated to write HTML content

Recently, I've been utilizing the lazySizes plugin for optimizing my images. However, I encountered an issue when trying to implement it for HTML content display. Is there a simpler way to achieve this and maintain my current HTML structure? $(&apo ...

Utilizing jQuery's nextUntil() method to target elements that are not paragraphs

In order to style all paragraphs that directly follow an h2.first element in orange using the nextUntil() method, I need to find a way to target any other HTML tag except for p. <h2 class="first">Lorem ipsum</h2> <p>Lorem ipsum</p> ...

Display HTML instead of text in print mode

Hello, I need help with printing HTML code, specifically an iframe. When I try to add my HTML iframe code, it only prints as plain text. I want to be able to see the actual iframe with its content displayed. Thank you. <script> const messages = [&apo ...

Are there any SVG libraries available that can create line graphs similar to those seen in Google Analytics?

The line graph in Google Analytics that is created using SVG is quite impressive. Are there any libraries available that can generate similar line graphs to those in Google Analytics? ...

Increasing the margin-left automatically in Bootstrap 3.0.0

I am looking to automatically generate margin-left in the ".card" class "style" element every time a post is entered on a page. My jQuery version is 1.12.4 This is my idea: If the .card CSS style has a margin-left of 0 and width of 479px, set position to ...

How do you vertically span a grid element across 3 rows using Material UI?

This particular scenario may appear to be straightforward, but the official documentation of Material UI lacks a clear example on how to achieve this. Even after attempting to nest the grid elements, I encountered an issue where the grid element on the ri ...

Mobile Windows Z-Index

Struggling with the z-index issue on a video tag in Windows Mobile, particularly when it comes to my search box. <div portal:substituteby='common/search::search'></div> The goal is for the search box to appear above the video. ...

default browser's drag and reposition feature

I'm trying to make an image draggable on my webpage by using default browser behavior, but it's not working for some reason. Here is the code snippet I'm using: <div style="position:relative;width:1000px; height:900px;border:solid;z-inde ...

JavaScript code to render a string variable passed by the PostController file within the Sails framework

How can I properly display a string variable in the postview.ejs file sent by the PostController.js in Sails? The variable being used is called 'val' [ ejs html javascript Sails express node.js ] PostController.js module.exports = { post : f ...

The onmessage event in the websocket client seems to be malfunctioning and is not triggering

In my implementation using node.js, I have set up a websocket server and client. The handshake process between the server and client appears as follows: Request URL: ws://localhost:8015/ Request Method: GET Status Code: 101 Switching Protocols Request ...

Tips for closing print window dialog during Protractor testing

Currently, I am performing end-to-end testing using protractor. During a specific test, I need to verify if the print button is successfully creating a PDF. When the test clicks on the button, it triggers a print window dialog as shown below: https://i.st ...

Having trouble customizing the active state of a react router navlink using css modules in React?

Objective I am attempting to add styles to the active route in a sidebar using css modules while still maintaining the base styles by assigning 2 classes. This is the code I have tried: <NavLink to={path} className={` ${classes.nav_ ...

How can you define a div that has a width of 100% along with specific padding?

I currently have a div with the following CSS styling: .mydiv{ position:absolute; top:0; left:0; width:100%; padding:7px; }​ When viewed in the browser, there is horizontal scrolling due to the padding (width 100% + 7px) See it ...

Troubleshooting Jqgrid Keyboard Navigation Problem

Here is a link to the jsfiddle code snippet. Upon adding jQuery("#grid").jqGrid('sortableRows'); into my JavaScript code, I encountered an issue where keyboard navigation no longer worked after sorting rows Below is the JavaScript code snippet: ...

What causes the jQuery mouseenter events to be activated in a random sequence?

I currently have a setup of 3 nested divs, resembling the concept of a Matryoshka doll. Each div has a mouseenter event function bound to it. When moving the mouse slowly from the bottom and entering layer three, the events occur in the following sequence ...

Updating HTML in Vue.js with data at a specific index value can be done by targeting

Experimenting with a combination of vue.js and vanilla to create a blackjack game. The card data is stored in the vue data() like this: data(){ return { cards: [ {id: 1, cardName: 'Ace of Spades', cardPic: ' ...

unable to retrieve the chosen item from the dropdown menu

How can I retrieve the value of the selected item from a dropdown menu without getting an undefined error? You can find my code on Jsfiddle. Can anyone spot what might be causing this issue? <select class="ddl_status" id="status_ddl_20" style="display ...

What is the best method for loading JSONP data in Internet Explorer?

This code snippet functions flawlessly in FF, Chrome and Safari, however IE does not accept it. $(function() { var access_token = location.hash.split('=')[1]; $.ajax({ type: "GET", dataType: "jsonp", cache: false, url: "htt ...

unique label for every new form included

For each button click, I am adding a new form. The challenge is having a unique label for every added form. Currently, the label changes for each form. How can I resolve this issue? Any suggestions? HTML: <div id="jointBuyer" class="JointBuyerDive" ...