CSS自定义滚动条样式
测试html内容
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div class="test">
测试滚动条测试滚动条测试滚动条测试滚动条测试滚动条测试滚动条测试滚动条测试滚动条测试滚测试滚动条测试滚动条测试滚动条测试滚动条测试滚动条测试滚动条测试滚动条测试滚动条测试滚动条动条测试滚动条测试滚动条测试滚动条测试滚动条测试滚动条测试滚动条测试滚动条测试滚动条测试滚动条测试滚动条测试滚动条测试滚动条
</div>
</body>
</html>
默认样式
.test{
height: 200px;
width: 200px;
background-color: aquamarine;
padding: 5px;
overflow: auto;
}
默认样式效果
![默认样式](https://i-blog.csdnimg.cn/blog_migrate/eb82dbbe6955aa8a60df48df63d8c681.png)
自定义后样式
.test::-webkit-scrollbar {
width: 2px;
height: 2px;
scrollbar-arrow-color:#898989;
}
.test::-webkit-scrollbar-thumb {
border-radius: 5px;
-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
background: rgba(0,0,0,0.2);
scrollbar-arrow-color:#898989;
}
.test::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
border-radius: 0;
background: rgba(0,0,0,0.1);
}
自定义样式效果
![自定义样式效果](https://i-blog.csdnimg.cn/blog_migrate/9cb0b5d2e041060be030b9c0d59da262.png)