<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
.box {
width: 300px;
height: 500px;
background-color: #000;
overflow-y: auto;
}
.box2{
width: 100%;
height: 200px;
margin-top: 20px;
background-color: #ccc;
}
/* 滚动条最外面的框架 */
.box::-webkit-scrollbar {
width: 10px;
}
/* 滚动条轨道 */
.box::-webkit-scrollbar-track {
background-color: #2adbd2;
border-radius: 0px 10px 10px 0;
}
/* 滚动条滑块 */
.box::-webkit-scrollbar-thumb {
background-color: #b383da;
border-radius: 5px;
}
</style>
<body>
<div class="box">
<div class="box2">
123
</div>
<div class="box2">
456
</div>
<div class="box2">
789
</div>
<div class="box2">
123
</div>
<div class="box2">
456
</div>
<div class="box2">
789
</div>
<div class="box2">
123
</div>
<div class="box2">
456
</div>
<div class="box2">
789
</div>
</div>
</body>
</html>
滚动条是依附在父元素身上的 所以在css里要选择父元素的类名