// 修改全局的scrollBar
::-webkit-scrollbar {
width: 8px;
margin: 0 1px;
background: #fdfdfd;
}
::-webkit-scrollbar:horizontal {
height: 8px;
}
::-webkit-scrollbar-button {
height: 0;
}
::-webkit-scrollbar-track {
border-radius: 4px;
}
::-webkit-scrollbar-track-piece {
background-color: #fdfdfd;
border-radius: 4px;
}
::-webkit-scrollbar-thumb {
width: 8px;
margin: 0 1px;
border-radius: 4px;
background: #c4c4c4;
}
::-webkit-scrollbar-thumb:hover {
background: #909090;
}
还有一个是公司集团使用的b-design样式
// 全局处理滚动条样式
::-webkit-scrollbar-track {
border-radius: 0;
background-color: #f2f3f8;
}
::-webkit-scrollbar-thumb {
border-radius: 0;
background-color: #dee2e7;
-webkit-transition: all .2s;
transition: all .2s;
border-radius: .5rem;
}
::-webkit-scrollbar-corner {
background-color: #f2f3f8;
}
::-webkit-scrollbar {
width: .5rem;
height: .5rem;
}
不过我更喜欢使用scss中的 @mixin
@mixin scrollBar{
&::-webkit-scrollbar-track-piece {
background: #d3dce6;
}
&::-webkit-scrollbar {
width: 6px;
}
&::-webkit-scrollbar-thumb {
background: #99a9bf;
border-radius: 20px;
}
}
然后通过@include使用
.wrap{
@include scrollbar;
overflow-y:auto;
}