Home > Web Front-end > CSS Tutorial > How to change browser scroll bar style using css

How to change browser scroll bar style using css

王林
Release: 2020-04-28 09:18:02
forward
3201 people have browsed it

How to change browser scroll bar style using css

Note: This method is only applicable to -webkit- kernel browser

The scroll bar appearance consists of two parts:

1. The overall scroll bar Slide rail

2. Scroll bar Slider in slide rail

In CSS, the scroll bar consists of 3 parts

name::-webkit-scrollbar //滚动条整体样式

name::-webkit-scrollbar-track //滚动条滑轨

name::-webkit-scrollbar-thumb //滚动条内部滑块
Copy after login

Note: The above 3 are pseudo-classes, please Change the name to the name of the element that needs to be changed

(Related video tutorial recommendation: css video tutorial)

For example: change the scroll bar style of the entire page

body::-webkit-scrollbar{ //先改变body的滚动条宽度

width: 8px;

}

body::-webkit-scrollbar-track{//再改变body的滚动条轨道颜色

background: rgb(200, 200, 200);

border-radius: 5px;

}

body::-webkit-scrollbar-thumb{//最后改变body的滚动条滑轨相关的样式

background: rgb(120, 120, 120);

border-radius: 5px;

}
Copy after login

You can add background, transparency, border, rounded corners and other attributes to the style to make the browser more beautiful.

Recommended tutorial: css quick start

The above is the detailed content of How to change browser scroll bar style using css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:jb51.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template