自定义滚动条样式

骑猪看日落 2022-01-14 13:17 531阅读 0赞

::-webkit-scrollbar //滚动条整体部分
::-webkit-scrollbar-button //滚动条两端的按钮
::-webkit-scrollbar-track // 外层轨道
::-webkit-scrollbar-track-piece //内层轨道,滚动条中间部分(除去)
::-webkit-scrollbar-thumb //滚动条里面可以拖动的那个
::-webkit-scrollbar-corner //边角
::-webkit-resizer ///定义右下角拖动块的样式

在这里插入图片描述

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>Document</title>
  8. </head>
  9. <body>
  10. <div class="bigBox">
  11. <div class="list1">
  12. <p style="height:800px;width: 200%">
  13. 默认样式
  14. </p>
  15. </div>
  16. <div class="list2">
  17. <p style="height:800px;width: 200%">
  18. 内容2<br>
  19. </p>
  20. </div>
  21. <div class="list3">
  22. <p style="height:800px;width: 200%">
  23. 内容3<br>
  24. </p>
  25. </div>
  26. <div class="list4">
  27. <p style="height:800px;width: 200%">
  28. 内容4<br>
  29. </p>
  30. </div>
  31. </div>
  32. </body>
  33. <script>
  34. </script>
  35. <style>
  36. body,html{
  37. background: linear-gradient(left,#03a9f4, #f71ab95e); /* 标准的语法 */
  38. background: -webkit-linear-gradient(left,#03a9f4, #f71ab95e); /* Safari 5.1 - 6.0 */
  39. background: -o-linear-gradient(left,#03a9f4, #f71ab95e); /* Opera 11.1 - 12.0 */
  40. background: -moz-linear-gradient(left,#03a9f4, #f71ab95e); /* Firefox 3.6 - 15 */
  41. }
  42. /*
  43. ::-webkit-scrollbar //滚动条整体部分
  44. ::-webkit-scrollbar-button //滚动条两端的按钮
  45. ::-webkit-scrollbar-track // 外层轨道
  46. ::-webkit-scrollbar-track-piece //内层轨道,滚动条中间部分(除去)
  47. ::-webkit-scrollbar-thumb //滚动条里面可以拖动的那个
  48. ::-webkit-scrollbar-corner //边角
  49. ::-webkit-resizer ///定义右下角拖动块的样式
  50. */
  51. .bigBox{
  52. width: 100%;
  53. background: green;
  54. }
  55. .bigBox div{
  56. width: 10%;
  57. float: left;
  58. height: 500px;
  59. margin-left:12%;
  60. overflow-y: scroll;
  61. }
  62. .bigBox .list1{
  63. background: pink
  64. }
  65. .bigBox .list2{
  66. background: red
  67. }
  68. .list2::-webkit-scrollbar
  69. {
  70. width: 12px;
  71. background-color: #000000;
  72. }
  73. .list2::-webkit-scrollbar-thumb
  74. {
  75. border-radius: 10px;
  76. background-color: #FFFFFF;
  77. border-radius: 0;
  78. }
  79. .list2::-webkit-scrollbar-button{
  80. background: green;
  81. width: 12px;
  82. height: 20px;
  83. color: green;
  84. content: "▲";
  85. }
  86. .list2::-webkit-resizer{
  87. background: orange;
  88. }
  89. .list3{
  90. background: #4F9D9D;
  91. }
  92. .list3::-webkit-resizer{border-radius:.3125rem;background-color:#2f4056}
  93. .list3::-webkit-scrollbar{width:12px;height:12px}
  94. .list3::-webkit-scrollbar-thumb{border-radius:5px;background-color:#0073aa;background-image:-webkit-linear-gradient(45deg,hsla(0,0%,100%,.4) 25%,transparent 25%,transparent 50%,hsla(0,0%,100%,.4) 50%,hsla(0,0%,100%,.4) 75%,transparent 75%,transparent)}
  95. .list4{
  96. background: #E800E8;
  97. }
  98. .list4::-webkit-scrollbar{
  99. width:12px;
  100. height:12px
  101. }
  102. .list4::-webkit-scrollbar-thumb{
  103. width:12px;
  104. background: linear-gradient(top,#00EC00,#424200);
  105. background: -webkit-linear-gradient(top,#00EC00,#424200);
  106. background: -moz-linear-gradient(top,#00EC00,#424200);
  107. background: -o-linear-gradient(top,#00EC00,#424200);
  108. border-radius: 5px;
  109. }
  110. </style>
  111. </html>

发表评论

表情:
评论列表 (有 0 条评论,531人围观)

还没有评论,来说两句吧...

相关阅读