vue中使用el-table调整行间距

本文介绍了在Vue项目中如何解决el-table行间距通过padding或margin无效的问题,通过利用table的特性,设置`-webkit-border-vertical-spacing`实现垂直间距的调整。同时,展示了详细代码示例,包括表格边框、单元格内边距、边框圆角等样式设置,实现了美观的表格布局效果。
摘要由CSDN通过智能技术生成

在vue中使用el-table但是行间距利用padding或者margin不起作用,是因为display使用的是table属性,所以我们要利用table特性来进行处理。
代码如下:

.el-table {
  width: 100%;
  margin-bottom: 20px;
  &::before {
    display: none;
  }
  .el-table__body {
    //-webkit-border-horizontal-spacing: 13px;  // 水平间距
    -webkit-border-vertical-spacing: 10px; // 垂直间距 设置的是行间距
  }
  //以下代码是实现边框效果
  thead th {
    font-size: 14px;
    color: #575757;
    &:nth-last-child(2) {
      border-right: 1px solid rgba(0, 0, 0, 0.1) !important;
      border-radius: 0 5px 5px 0;
      right: 1px;
    }
    
  }
  thead th,
  .el-table__row td {
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    padding: 10px 0;
    border-top: 1px solid rgba(0, 0, 0, 0.1) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
    &:first-child {
      border-left: 1px solid rgba(0, 0, 0, 0.1) !important;
      border-radius: 5px 0 0 5px;
    }
  }
  .el-table__row > td {
    font-size: 12px;
    color: #333333;
    &:last-child {
      border-right: 1px solid rgba(0, 0, 0, 0.1) !important;
      border-radius: 0 5px 5px 0;
      right: 1px;
    }
  }
  .el-table__body tr:hover > td.el-table__cell {
    background-color: rgba(0, 110, 255, 0.05);
  }
  .el-table__fixed::before {
    display: none;
  }
}

实现效果:
在这里插入图片描述

  • 8
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

是小许同学吖

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值