css设置滚动条样式不生效【antDesign UI Table滚动条样式无法自定义 解决方案】

  1. 检查一下是否设置overview
  2. 检查设置的元素是否是滚动条所在的元素
  3. 通过获取到节点设置scrollTop看看滚动条是否正确
  4. 检查完后仍不生效,检查节点是否设置了 scrollbar-color/scrollbar-width 属性
css 复制代码
  【问题4解决方案】
  
  .ant-table-body {
    scrollbar-color: auto !important; /* 重置为 auto,让 webkit 伪元素完全接管 */
    scrollbar-width: auto !important; /* 重置为 auto */

    &::-webkit-scrollbar {
      width: 4px !important;
      height: 4px !important;
    }
    &::-webkit-scrollbar-track {
      background: transparent !important;
    }
    &::-webkit-scrollbar-thumb {
      background: transparent !important;
      border-radius: 2px !important;
    }
    &::-webkit-scrollbar-button {
      display: none !important;
    }
  }

  /* 容器 hover 时显示滚动条 */
  &:hover {
    .ant-table-body {
      &::-webkit-scrollbar-track {
        background: var(--Surface-Secondary-50, #f4f4f4) !important;
      }
      &::-webkit-scrollbar-thumb {
        background: var(--Text-Body, #525252) !important;
      }
      &::-webkit-scrollbar-button {
        display: none !important;
      }
    }
  }
相关推荐
deli00710 分钟前
1 个汉字算几个 token?实测中英文 prompt 与代码的编码差异
前端
无限聚核17 分钟前
抖音 certificate.prepare 之后怎么验券?和美团 msconsume 差在哪,无限聚核
前端·微信小程序
2603_9658966226 分钟前
Grid 网格布局|CSS 二维页面排版体系
前端·css
有味道的男人42 分钟前
搜好货平台关键词商品搜索接口:分页容错与商品数据轻量化提取方案
服务器·前端·javascript
lovingsoft1 小时前
Chrome Lighthouse 详解
前端·chrome
Qlly2 小时前
全栈工程师怎么接需求?从一句「加个功能」聊到能开发、能验收
前端·后端
多喝水身体棒2 小时前
# CSS Grid布局入门,二维布局再也不用float了
css
马可家的菠萝2 小时前
你的微信“文件传输助手”,是不是已经成了第二个网盘?
前端·后端·架构
略略略啦2 小时前
Vibe Coding 基于Spec DD和TDD的实践指南
前端
shmily麻瓜小菜鸡2 小时前
前端实现图片与PDF文字识别敏感信息打码方案
前端·pdf·状态模式