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

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

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
修改 Element UI 表格组件的样式,可以使用自定义样式类和覆盖默认样式。以下是一些基本的步骤: 1. 在 Vue 组件引入 Element UI 表格组件。 ```javascript <template> <el-table :data="tableData"> <el-table-column prop="name" label="Name"></el-table-column> <el-table-column prop="age" label="Age"></el-table-column> <el-table-column prop="address" label="Address"></el-table-column> </el-table> </template> <script> import { ElTable, ElTableColumn } from 'element-ui'; export default { components: { ElTable, ElTableColumn, }, data() { return { tableData: [ { name: 'John Doe', age: 30, address: '123 Main St', }, // ... ], }; }, }; </script> ``` 2. 在组件定义自定义样式类。 ```css .table-wrapper { border: 1px solid #ccc; } .el-table__header { background-color: #f5f5f5; } .el-table__body { background-color: #fff; } ``` 3. 将自定义样式类应用于表格组件。 ```javascript <template> <div class="table-wrapper"> <el-table :data="tableData" class="my-table"> <el-table-column prop="name" label="Name"></el-table-column> <el-table-column prop="age" label="Age"></el-table-column> <el-table-column prop="address" label="Address"></el-table-column> </el-table> </div> </template> <style> .my-table { width: 100%; } .el-table__header { background-color: #f5f5f5; } .el-table__body { background-color: #fff; } </style> ``` 在上面的示例,我们在 `div` 元素上应用了 `.table-wrapper` 样式类,并在表格组件上应用了 `.my-table` 样式类。然后,我们覆盖了表格组件的默认样式,例如表头和表体的背景颜色。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值