一、 div 中设置 在overflow:auto的当前级下设置
<div class="scrollCanner">
<div class="scrollContent">
.....
//填充的内容
.....
</div>
</div>
.scrollCanner{
width:500px;
height:100vh;
overflow:hidden;
}
.scrollContent{
overflow-x:hidden;
overflow-y:auto;
}
.scrollContent::-webkit-scrollbar {
width: 4px;
}
.scrollContent::-webkit-scrollbar-thumb {
border-radius: 10px;
background: #3c506e; //上层块颜色
}
.scrollContent::-webkit-scrollbar-thumb:hover {
background: #103264; //上层块颜色
}
.scrollContent::-webkit-scrollbar-track {
border-radius: 10px;
background: #bab9b9; //底层背景块颜色
}
效果图如下:
二、全局定义
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-thumb {
border-radius: 0px;
background: #3c506e; /* 上层 */
}
::-webkit-scrollbar-thumb:hover{
background: #103264; /* 上层 */
}
::-webkit-scrollbar-track {
border-radius: 0px;
background: #bab9b9;
}