在实现溢出隐藏以及溢出滚动时出现默认滚动条样式不太美观,以下代码帮助美化滚动条样式:
美化前: 美化后:
代码:
//滑动条背景设置
::-webkit-scrollbar-track-piece {
background-color: #fff;
-webkit-border-radius: 0
}
::-webkit-scrollbar {
width: 10px;
height: 10px
}
//滑动块样式
::-webkit-scrollbar-thumb {
height: 50px;
background-color: #e2e2e2;
-webkit-border-radius: 6px;
outline: 2px solid #fff;
outline-offset: -2px;
border: 2px solid #fff;
filter: alpha(opacity = 50);
-moz-opacity: 0.5;
-khtml-opacity: 0.5;
opacity: 0.5
}
//滑动块hover样式
::-webkit-scrollbar-thumb:hover {
height: 50px;
background-color: #d6d6d6;
-webkit-border-radius: 6px
}