1.全局设置
::-webkit-scrollbar {width: 4px;height: 4px;
}::-webkit-scrollbar-thumb {border-radius: 5px;-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);background-color: #99a9bf;
}::-webkit-scrollbar-track {-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);border-radius: 5px;background-color: #d3dce6;
2.单独设置滚动条样式
.container {max-height: 100vh;overflow-y: scroll;&::-webkit-scrollbar {width: 4px;height: 4px;
}&::-webkit-scrollbar-thumb {border-radius: 5px;-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);background-color: #99a9bf;
}&::-webkit-scrollbar-track {-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);border-radius: 5px;background-color: #d3dce6;
}}
注:只有内容超出盒子高度或者宽度,才会出现纵向或者横向的滚动条 转载于
https://blog.csdn.net/Fansr_/article/details/119784638














