如何实现给table表头加斜线

方法一:

    <el-table
      :data="tableData"
      :span-method="objectSpanMethod"
      border
      style="width: 100%; margin-top: 20px"
    >
      <el-table-column label="数量" width="180">
         <!-- 在方法二中,无需嵌套下面这行 -->
        <el-table-column prop="name" label="Name" />
      </el-table-column>
      <el-table-column prop="amount1" label="Amount 1" />
      <el-table-column prop="amount2" label="Amount 2" />
      <el-table-column prop="amount3" label="Amount 3" />
    </el-table>

 需要注意的是:下列样式在style中加scoped会不生效,可以自行给每个类名加 :deep() 来实现

.el-table thead.is-group th {
    background: none;
    padding: 0px;
  }

  .el-table thead.is-group tr:first-of-type th:first-of-type {
    border-bottom: none;
    /*中间的横线去掉*/
  }

  .el-table thead.is-group tr:first-of-type th:first-of-type div.cell {
    text-align: right;
    /*上边文字靠右*/
  }

  .el-table thead.is-group tr:last-of-type th:first-of-type div.cell {
    text-align: left;
    /*下边文字靠左*/
  }
  /*实现斜线代码*/
  .el-table thead.is-group tr:first-of-type th:first-of-type:before {
    content: "";
    position: absolute;
    width: 1px;
    height: 200px;
    /*斜线的长度*/
    top: 0;
    left: 0;
    background-color: grey;
    opacity: 0.2;
    display: block;
    /*调整斜线的角度*/
    transform: rotate(286deg);
    /*调整斜线的角度*/
    -webkit-transform-origin: top;
    transform-origin: top;
  }

方法二

thead tr:first-child th:first-child {
  position: relative;
  background: linear-gradient(
    28deg,
    transparent 50%,
    #d7d5d5 50%,
    #d7d5d5 50.5%,
    transparent 50.5%
  );
}
thead tr:first-child th:first-child .cell{
   position: absolute;
  top: 0px;
  right: 0;
  width: 100px;
  font-size: 14px;
}
thead tr:first-child th:first-child:after{
  content: 'Name';
  position: absolute;
  left: 10px;
  // bottom: 10px;
  color: #909399;
}

 linear-gradient() 函数用于创建一个表示两种或多种颜色线性渐变的图片,如果不指定方向,默认从上到下渐变。

linear-gradient(direction, color-stop1, color-stop2, ...)

 direction:用角度值指定渐变的方向(或角度)。

color-stop:用于指定渐变的起止颜色。

background-image: linear-gradient(45deg,red, yellow, blue);

 

  • 2
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值