Modify the default scroll bar style in the front-end project (summary)

Modify the default scroll bar style in the front-end project (summary)

I have written many projects that require changing the default style of the scroll bar, and I don’t want to download and introduce plug-ins separately. Therefore, I modify the style of the default scroll bar purely with CSS. This time I will unify the methods and directly post the code.

            &::-webkit-scrollbar {
              //Scrollbar background width: 16px;
              background: #191a37;
              height: 14px;
            }

            &::-webkit-scrollbar-track,
            &::-webkit-scrollbar-thumb {
              border-radius: 999px;
              width: 20px;
              border: 5px solid transparent;
            }

            &::-webkit-scrollbar-track {
              box-shadow: 1px 1px 5px #191a37 inset;
            }

            &::-webkit-scrollbar-thumb {
              //Modify the scroll bar slider style width: 20px;
              min-height: 20px;
              background-clip: content-box;
              box-shadow: 0 0 0 5px #464f70 inset;
            }

            &::-webkit-scrollbar-corner {
              background: #191a37;
            }

This is a pretty complete modification.

The one below is very concise. Worth a try

            &::-webkit-scrollbar {
              width: 6px;
              height: 6px;
              background: transparent;
            }

            &::-webkit-scrollbar-thumb {
              background: transparent;
              border-radius: 4px;
            }

            &:hover::-webkit-scrollbar-thumb {
              background: hsla(0, 0%, 53%, 0.4);
            }

            &:hover::-webkit-scrollbar-track {
              background: hsla(0, 0%, 53%, 0.1);
            }

The advantage of this is that the modified scroll bar will be displayed only when the mouse is moved, which is a good experience

(Prompt the code to hide the scroll bar of a certain axis)

overflow-x:hidden;

I thought it was none before, and it didn't change for a long time.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

<<:  Detailed graphic explanation of mysql query control statements

>>:  Web Design Help: Web Font Size Data Reference

Recommend

Detailed example of MySQL exchange partition

Detailed example of MySQL exchange partition Pref...

TypeScript Enumeration Type

Table of contents 1. Overview 2. Digital Enumerat...

Solution to the problem that input in form cannot be submitted when disabled

I wrote a test program before, in which adding and...

Sharing experience on the priority of CSS style loading

During the project development yesterday, I encoun...

Example code of CSS layout at both ends (using parent's negative margin)

Recently, during the development process, I encou...

Vue makes div height draggable

This article shares the specific code of Vue to r...

Summary of Linux date command knowledge points

Usage: date [options]... [+format] or: date [-u|-...

js to write the carousel effect

This article shares the specific code of js to ac...

Logrotate implements Catalina.out log rotation every two hours

1. Introduction to Logrotate tool Logrotate is a ...

Common methods and problems of Docker cleaning

If you use docker for large-scale development but...

docker logs - view the implementation of docker container logs

You can view the container logs through the docke...

12 Javascript table controls (DataGrid) are sorted out

When the DataSource property of a DataGrid control...

Detailed steps to deploy lnmp under Docker

Table of contents Pull a centos image Generate ng...