css-自定义滚动条

<template>
  <div style=" 50%;height: 100%;overflow-y: auto" class="zm-scrollbar">
    <div style="height: 6000px"></div>
  </div>
</template>

<script>
  export default {
    name: "a17"
  }
</script>

<style>
  .zm-scrollbar {
    --scrollbar- 0px;
    cursor: pointer;
  }

  .zm-scrollbar * {
    cursor: auto;
  }

  .zm-scrollbar:hover {
    --scrollbar- 8px;
  }

  /*滚动条整体*/
  .zm-scrollbar::-webkit-scrollbar {
     var(--scrollbar-width);
  }

  /*滑轨样式*/
  .zm-scrollbar::-webkit-scrollbar-track {
    box-shadow: 0 0 calc(var(--scrollbar-width) / 2) #cccccc inset;
    border-radius: calc(var(--scrollbar-width) / 2);
  }

  /*滑块样式*/
  .zm-scrollbar::-webkit-scrollbar-thumb {
    border-radius: calc(var(--scrollbar-width) / 2);
    background-color: #999999;
  }

  .zm-scrollbar::-webkit-scrollbar-thumb:hover {
    background-color: #666666;
  }
</style>
原文地址:https://www.cnblogs.com/linding/p/14990575.html