使用CSS自定义滚动条样式

有时候我们会感觉滚动条的样子不好看,需要自定义,那么可以加在style里面加入以下代码,颜色和大小可以根据自身情况自定义。

::-webkit-scrollbar-track-piece {
  width:13px;
  border-right:1px solid #EEE;
  border-left:1px solid #e4e4e4;
  background-color:#f0f0f0;
  background-image:-webkit-linear-gradient(left,#f0f0f0,#FFF);
}

::-webkit-scrollbar {
  width:13px;
  height:13px;
}

::-webkit-scrollbar-thumb {
  position:relative;
  min-height:25px;
  border-radius:9999px;
  background-color:#c2c2c2;
  background-clip:padding-box;
}

::-webkit-scrollbar-thumb:vertical {
  border-top:0 solid transparent;
  border-right:2px solid transparent;
  border-bottom:0 solid transparent;
  border-left:3px solid transparent;
}

::-webkit-scrollbar-thumb:horizontal {
  border-top:3px solid transparent;
  border-right:0 solid transparent;
  border-bottom:2px solid transparent;
  border-left:0 solid transparent;
}

::-webkit-scrollbar-thumb:active {
  background-color:#7d7d7d;
}

除特别注明外,本站所有文章均为原创,转载请注明原文链接:https://www.myblogbo.com/article/8.html

 Top