CSS自定义滚动条样式

转自:http://www.yiyifly.com/blog/

下面是代码:
html {
overflow: auto;
}
body {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
overflow-y: scroll;
overflow-x: hidden;
}

/*滚动条宽度*/
::-webkit-scrollbar {
8px;
}

/* 轨道样式 */
::-webkit-scrollbar-track {

}

/* Handle样式 */
::-webkit-scrollbar-thumb {
border-radius: 10px;
background: rgba(0,0,0,0.2);
}

/*当前窗口未激活的情况下*/
::-webkit-scrollbar-thumb:window-inactive {
background: rgba(0,0,0,0.1);
}

/*hover到滚动条上*/
::-webkit-scrollbar-thumb:vertical:hover{
background-color: rgba(0,0,0,0.3);
}
/*滚动条按下*/
::-webkit-scrollbar-thumb:vertical:active{
background-color: rgba(0,0,0,0.7);
}

原文地址:https://www.cnblogs.com/golddream/p/5025204.html