css原生table添加滚动条后改变滚动条的大小后让thead与tbody 对齐

HTML:

html 复制代码
<table class="layui-table cic-table">
   <thead>
       <tr>
           <td class="td-title"></td>
           <td class="td-title row-title"></td>
       </tr>
   </thead>
   <tbody>
       <tr>
           <td class="td-title"></td>
           <td class="first-title"></td>
       </tr>
   </tbody>
</table>

CSS:

css 复制代码
.cic-table tbody {
   	max-height: 330px;
    display: block;
    overflow-y: auto;
}
.cic-table thead, .cic-table tbody tr {
    width: 100%;
    display: table;
    table-layout: fixed;
}
.cic-table thead {
    width: calc(100% - 3px); /*减去默认滚动条的宽度,让thead 与tbody 对齐*/
}
/*改变滚动条的宽度和样式*/
.cic-table tbody::-webkit-scrollbar { width: 3px;}
.cic-table tbody::-webkit-scrollbar { width: 3px;}
.cic-table tbody::-webkit-scrollbar-track{background-color:#f0f0f0;}
.cic-table tbody::-webkit-scrollbar-thumb{background-color:#CCCCCC;}
.cic-table tbody::-webkit-scrollbar-thumb:hover {background-color:#CCCCCC;}
.cic-table tbody::-webkit-scrollbar-thumb:active {background-color:#CCCCCC;}
相关推荐
前端snow9 小时前
ai agent --- postgreSQL 关系型数据库
前端
卷无止境9 小时前
ECharts:把数据变成故事的可视化利器
前端
Eric_见嘉10 小时前
在职前端 Skill 和 MCP 分享
前端·后端·agent
liangshanbo121510 小时前
面试题:如何优化 Webpack 的打包速度?
前端·webpack·node.js
wengad10 小时前
从 wangEditor 迁到 wangEditor-next
前端·javascript·vue.js
行者-全栈开发11 小时前
【前端/JS框架】CVE-2026-3854:GitHub Enterprise Server X-Stat注入XSS漏洞深度剖析与紧急修复指南
前端·javascript·github
计算机魔术师12 小时前
AMD砸82亿买下李飞飞,这次不卖芯片卖什么?
前端
hzxpaipai13 小时前
杭州企业官网怎么建设?从策划到上线的5步建站方法
运维·服务器·前端·网络
怕浪猫13 小时前
2026年金九银十,我面了22个前端
前端·javascript·面试
IT_陈寒13 小时前
Vue 这个响应式陷阱,我的头发都掉没了
前端·人工智能·后端