滚动条样式调整

发布时间 2023-09-28 09:38:13作者: 借你耳朵说爱你

1.\public\css\custom.css

/*滚动条STR*/
/* 滚动条的宽度 */
::-webkit-scrollbar {
    width: 10 px;
}
/* 灰色,但是透明度为0,即完全透明(透明度未指定,默认为1,即完全不透明)。
!important表示这个样式规则具有最高优先级,将覆盖其他相同属性的样式规则。 */
/* 滚动条的轨道 */
::-webkit-scrollbar-track {
    background-color: rgba(232, 232, 232, 1) !important;
}
/* 滚动条的拇指 */
::-webkit-scrollbar-thumb {
    background-color: rgba(136, 136, 136, 1) !important;
}
/* 当鼠标悬停在滚动条 */
::-webkit-scrollbar-thumb: hover {
    background-color: rgba(100, 100, 100, 1) !important;
}
/* 滚动条在被点击时 */
::-webkit-scrollbar-thumb: active {
    background-color: rgba(100, 100, 100, 1) !important;
}
/*滚动条END*/

2.\src\APP.vue

::-webkit-scrollbar {
  width: .5em;
  height: .5em;
  background-color: transparent;
  border-radius: 0;
}
//修改第4个参数(透明度)
::-webkit-scrollbar-thumb {
  background-color: #000000;
  background-color: rgba(0, 0, 0, 0.05);
  border-radius: 0;
}
//修改第4个参数(透明度)
::-webkit-scrollbar-thumb:hover {
  background-color: #000000;
  background-color: rgba(0, 0, 0, 0.35);
}

选择上面两种方式其一即可。