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',差别很大卡了我半天

相关推荐
A黄俊辉A1 天前
uniapp webview中实现 app和内嵌的H5双向通信
vue.js·json
大蓝头1 天前
安装包UI美化之路-nsNiuniuSkin全新UI调试与预览方法
ui·electron·安装包·截图控件·截屏控件
honkun61 天前
vue 表格组件 vxe-table 配置 ajax 请求自动加载数据与表单查询
vue.js·vxe-table
kybs19911 天前
全球灾害数据分析可视化 毕业设计-附源码66794
vue.js·spring boot·mysql·安全·django·c#·asp.net
雪芽蓝域zzs1 天前
第26章:ECharts 自定义主题 + 页面一键切换主题(深色 / 浅色两套)
vue.js·echars
雪芽蓝域zzs1 天前
第22章:ECharts 图表联动(多图表交互联动)
vue.js·echars
慧都小项1 天前
当边缘AI上产线:QtitanDocking 如何让工业 HMI 实现多视图协同
人工智能·qt·ui·边缘计算·qt6.3
daols881 天前
vue 表格组件 vxe-table 实现虚拟滚动与无需滚动加载
vue.js·vxe-table
雪芽蓝域zzs1 天前
第18章:ECharts 折线图 + 标记点、标记线,自定义 tooltip
vue.js·echars
雪芽蓝域zzs1 天前
第24章:ECharts 地图组件(基础行政区地图,若依 Vue3)
vue.js·echars