【element-ui修改表格样式】项目中常用修改el-table的样式

本文提供了修改Vue3和Vue2中ElementUI表格样式的详细方法,包括斑马线背景、表头背景、行背景、表头字体颜色、行内线颜色、边框颜色和高度、字体颜色以及鼠标悬停时的背景色。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、修改斑马线表格背景

vue3使用 :

::v-deep .el-table--striped .el-table__body tr.el-table__row--striped td {
    background: #ccc;
  }

 vue2使用:

/deep/ .el-table--striped .el-table__body tr.el-table__row--striped td {
    background: #ccc;
  }

2、修改表格头部背景

vue3使用 :

::v-deep .el-table th{
    background: #CCCCCC;
  }

  vue2使用:

/deep/ .el-table th{
    background: #CCCCCC;
  }

3、修改表格行背景

 vue3使用 :

::v-deep .el-table tr{
   background: #eee;
  }

 vue2使用 :

/deep/ .el-table tr{
   background: #eee;
  }

4、修改表头字体颜色

  vue3使用 :

::v-deep .el-table thead {
    color: #ccc;
    font-weight: 700;
  }

  vue2使用 :

/deep/ .el-table thead {
    color: #ccc;
    font-weight: 700;
  }

5、修改行内线的颜色

   vue3使用 :

::v-deep .el-table td,.building-top .el-table th.is-leaf {
    border-bottom:  2px solid #eee;
  }

    vue2使用 :

/deep/ .el-table td,.building-top .el-table th.is-leaf {
    border-bottom:  2px solid #eee;
  }

6、修改表格最底部边框颜色和高度

   vue3使用 :

::v-deep .el-table::before{
   border-bottom:  1px solid #ccc;
    height: 3px
  }

    vue2使用 :

/deep/ .el-table::before{
   border-bottom:  1px solid #ccc;
    height: 3px
  }

7、修改表格内容字体颜色和字体大小

   vue3使用 :

::v-deep .el-table{
    color: #6B91CE;
    font-size: 14px;
  }

   vue2使用 :

/deep/ .el-table{
    color: #6B91CE;
    font-size: 14px;
  }

8、修改表格鼠标悬浮hover背景色

    vue3使用 :

::v-deep .el-table--enable-row-hover .el-table__body tr:hover>td {
    background-color: pink;
}

   vue2使用 :

/deep/ .el-table--enable-row-hover .el-table__body tr:hover>td {
    background-color: pink;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值