element-ui table表格 tr间距\行间距设置

效果图

代码实现

html 复制代码
<el-table :data="testData" :header-cell-style="{
            color: '#65AEC8 !important',
            height: '20px !important',
            padding: '0 0 4px 0 !important',
            borderBottom: '2px solid #4A7EC6 !important',
            background: 'transparent !important',
          }" 
          :cell-style="{
            padding: '0 !important',
            borderBottom: '2px solid transparent !important', /* 透明边框模拟间距 */
            backgroundClip: 'padding-box', /* 确保背景不延伸到边框 */
            backgroundColor: '#031c50 !important',
          }" stripe class="log-table">
            <el-table-column label="规格型号" align="center" prop="规格型号"></el-table-column>
            <el-table-column label="板类型" align="center" prop="板类型"></el-table-column>
            <el-table-column label="流水号" align="center" prop="流水号"></el-table-column>
            <el-table-column label="库区" align="center" prop="库区"></el-table-column>
            <el-table-column label="库位" align="center" prop="库位"></el-table-column>
            <el-table-column label="存取操作" align="center" prop="存取操作"></el-table-column>
            <el-table-column label="存取时间" width="200" align="center" prop="存取时间"></el-table-column>
</el-table>

重点说明

这两行基本就能实现tr之间的透明间距

html 复制代码
borderBottom: '2px solid transparent !important', /* 透明边框模拟间距 */
backgroundClip: 'padding-box', /* 确保背景不延伸到边框 */

如果想要th\tr之间都有间距可以给table设置如下样式

html 复制代码
table {
  border-collapse: separate; /* 必须是 separate */
  border-spacing: 0 10px; /* 水平 垂直间距 */
}

注:backgroundColor: '#031c50 !important',这个千万不要写成background: '#031c50 !important',差别很大卡了我半天

相关推荐
cll_8692418916 分钟前
一个好看的Wordpress博客文字css样式
前端·css·ui
Bad_Shepherd26 分钟前
vue-element-plus-admin添加自定义svg图标,并且图标选择组件可选自定义图标
vue.js·elementui·前端框架
会周易的程序员3 小时前
Mermaid Renderer:一款的图表可视化小工具
前端·vue.js·流程图·mermaid
johnny2334 小时前
UI新革命?GenUI、WanDB-OpenUI、thesysdev-OpenUI、A2UI、AG-UI、MCP-UI
ui
天天进步201513 小时前
UI-TARS 源码解析 #10:parse_action 源码解析:如何用 AST 安全解析模型生成的函数调用?
安全·ui
慧一居士17 小时前
Element Plus 按需引入的配置使用说明和完整示例
前端·vue.js
CoderWeen21 小时前
我写了个能一步步点着看的 Dijkstra 可视化项目(Vue3 + Leaflet + Generator)
前端·javascript·vue.js
FuckPatience1 天前
Telerik UI for WPF 值不能为null。参数名:key
ui·wpf
无人生还1 天前
第 1 篇:从 Vue3 到 React 的思维转变
前端·vue.js·react.js
就业发动机1 天前
我用 Tauri 做了一个约 1.5 MB 的开源屏幕标注工具:MarkerOn
vue.js·rust