话不多说,先上图,最下面有源码
然后,然后,解决后让人扣脚的代码来了
<!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>
<style>
.test {
width: 200px;
height: 200px;
overflow: auto;
float: left;
margin: 5px;
border: none;
background-color: #eeee;
}
.scrollbar {
width: 300px;
height: 300px;
margin: 0 auto;
}
.test-1::-webkit-scrollbar {
/*滚动条整体样式*/
width: 10px;
/*高宽分别对应横竖滚动条的尺寸*/
height: 1px;
}
.test-1::-webkit-scrollbar-thumb {
/*滚动条里面小方块*/
border-radius: 10px;
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
background: #535353;
}
.test-1::-webkit-scrollbar-track {
/*滚动条里面轨道*/
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
border-radius: 10px;
background: #ededed;
}
/* 下面横向滚动条原理同上
在最后加上 :horizontal
*/
.test-1::-webkit-scrollbar:horizontal {
width: 20px;
height: 20px;
}
.test-1::-webkit-scrollbar-thumb:horizontal {
background-color: aquamarine;
}
.test-1::-webkit-scrollbar-track:horizontal {
background: blueviolet;
}
</style>
<body>
<div class="test test-1">
<div class="scrollbar"></div>
</div>
</body>
</html>
对,你没看错,就是这样