Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of modifying browser scroll bar style by CSS

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "the method of CSS modifying browser scroll bar style". In daily operation, I believe that many people have doubts about the method of CSS modifying browser scroll bar style. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "CSS modify browser scroll bar style". Next, please follow the editor to study!

Before we customize the scroll bar style, we first need to understand the structure of the scroll bar. Generally speaking, the scroll bar consists of two parts: one is the part that can slide, which we call the slider; the other is the track of the scroll bar, that is, the track of the slider. Generally speaking, for the sake of beauty, the color of the slider is darker than that of the track.

First, introduce the CSS code related to the scroll bar and what they mean.

::-webkit-scrollbar: refers to the whole part of the scroll bar. Its properties include width,height,background, etc.

::-webkit-scrollbar-button: the buttons on both sides of the scroll bar. You can hide it with display:none when you don't need it

:-webkit-scrollbar-track: refers to the outer track part, which can be hidden with display:none when not needed, or you can add the color you want.

::-webkit-scrollbar-track-piece: refers to the inner track part, that is, the middle part of the scroll bar

::-webkit-scrollbar-thumb: refers to the part of the scroll bar that can be dragged, that is, the slider

::-webkit-scrollbar-corner: refers to the corner part

::-webkit-resizer: he uses it to define the style of the slider in the lower right corner

But the most commonly used are the whole part of the scroll bar (- webkit-scrollbar), the slider (- webkit-scrollbar-thumb) and the outer track (- webkit-scrollbar-track).

Next, we hide the excess part of the div box, set the scroll bar style for div, and see how to use CSS to achieve the scroll bar style.

HTML section:

Haveaniceday

Haveaniceday

Haveaniceday

Haveaniceday

Haveaniceday

Haveaniceday

Haveaniceday

Haveaniceday

Haveaniceday

Haveaniceday

Haveaniceday

Haveaniceday

Haveaniceday

Haveaniceday

Haveaniceday

Haveaniceday

Haveaniceday

Haveaniceday

Haveaniceday

Haveaniceday

CSS section:

.scroll {

Margin:100pxauto

Border:1pxsolid#000

Width:200px

Height:300px

Overflow:auto

}

.clients::-webkit-scrollbar {

Width:10px

Height:10px

}

/ * normal slider style * /

.clients::-webkit-scrollbar-thumb {

Background-color:rgba (0pr 0pl 0pl .05)

Border-radius:10px

-webkit-box-shadow:inset1px1px0rgba (0J. 0J. 1)

}

/ * the style of the slider when the mouse hovers over the control pointed to by this class * /

.scroll: hover::-webkit-scrollbar-thumb {

Background-color:rgba (0J. 0J. 2)

Border-radius:10px

-webkit-box-shadow:inset1px1px0rgba (0J. 0J. 1)

}

/ * the style of the slider when the mouse hovers over the slider * /

.clients::-webkit-scrollbar-thumb:hover {

Background-color:rgba (0penny 0penny .4)

-webkit-box-shadow:inset1px1px0rgba (0J. 0J. 1)

}

/ * normal backbone * /

.clients::-webkit-scrollbar-track {

Border-radius:10px

-webkit-box-shadow:inset006pxrgba (0pd0re0pc0p0p0)

Background-color:white

}

/ * the backbone part of the mouse hovering over the scroll bar * /

.clients::-webkit-scrollbar-track:hover {

-webkit-box-shadow:inset006pxrgba (0pd0re0pl .4)

Background-color:rgba (0pd0re0pl. 01)

}

At this point, the study on "CSS's method of modifying the browser scroll bar style" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report