很多时候浏览器自定义的scrollbar风格与我们自己网页不符,我们就需要自定义scrollbar风格
有关scrollbar的结果
下面是我的效果图:
当然你也可以自定义其他风格
CSS实现方法
.container{
position: relative;
display: flex;
flex-direction: column;
max-height: 200px;
overflow-y: scroll;
padding: 5px;
margin-top: 20px;
}
.container::-webkit-scrollbar{
width: 5px;
background-color: #F5F5F5;
}
.container::-webkit-scrollbar-track{
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
border-radius: 5px;
background-color: #F5F5F5;
}
.container::-webkit-scrollbar-thumb{
border-radius: 5px;
background-color: #555;
}