在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;
  }
}

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

Logo

基于 Vue 的企业级 UI 组件库和中后台系统解决方案,为数万开发者服务。

更多推荐