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;}
相关推荐
万少8 分钟前
用腻了 WorkBuddy 的默认界面?这个开源小工具给它换上了毛玻璃
前端·javascript·后端
海上彼尚4 小时前
Nodejs也能写Agent - 16.LangGraph篇 - 条件分支与循环
前端·后端·langchain·node.js
To_OC5 小时前
从 “卡死半天” 到 “打字机效果”:大模型流式输出前端实现全记录
前端·javascript·llm
SoaringHeart5 小时前
Flutter最佳实践:键盘辅助视图输入框天添加图片附件
前端·flutter
kyriewen6 小时前
我看完这篇安全论文——AI推荐的npm包,92%是编出来的
前端·javascript·ai编程
小心我捶你啊7 小时前
数据采集和Web解锁不是一回事,从用途到规则区分
前端·爬虫·网络协议
hunterandroid7 小时前
[鸿蒙从零到一] ArkUI 基础组件实战:Text、Image、Button 与 TextInput
前端
fsssb8 小时前
Chromium 源码学习笔记(五):一次点击,在进入 JS 之前先经历了什么?
前端
hunterandroid8 小时前
WorkManager 可靠性实战:唯一任务、重试与幂等设计
android·前端