Element-UI的使用——表格el-table组件去除边框、滚动条设置、隔行变色、去除鼠标悬停变色效果(基于less)

javascript 复制代码
// Element-ui table表格去掉所有边框,如下:
// 备注:若去掉所有边框,可自行将头部边框注释掉即可
// 该样式写在style scoped外面
 
在el-table 中添加class="customer-table"类名
//去掉每行的下边框
  /deep/ .el-table td.el-table__cell,/deep/ .el-table th.el-table__cell.is-leaf {
    border-bottom: none;
  } 

// 去掉表格单元格边框
.customer-table th{
    border:none;
  }
.customer-table td,.customer-table th.is-leaf {
  border:none;
}
// 表格最外边框
.el-table--border, .el-table--group{
  border: none;
}
// 头部边框
.customer-table thead tr th.is-leaf{
  border: 1px solid #EBEEF5;
  border-right: none;
}
.customer-table thead tr th:nth-last-of-type(2){
  border-right: 1px solid #EBEEF5;
}
// 表格最外层边框-底部边框
.el-table--border::after, .el-table--group::after{
  width: 0;
}
.customer-table::before{
  width: 0;
}
.customer-table .el-table__fixed-right::before,.el-table__fixed::before{
  width: 0;
}
// 表格有滚动时表格头边框
.el-table--border th.gutter:last-of-type {
    border: 1px solid #EBEEF5;  
    border-left: none;
}
// 去除边框线
/deep/ .el-table::before {
    height: 0;
}

修改滚动条的样式,例如设置表格滚动条的颜色、宽度、 背景颜色等:

javascript 复制代码
  /deep/ .el-table__body-wrapper::-webkit-scrollbar-thumb {
    background-color: #2751be;
    border-radius: 6px;
  }
  /deep/ .el-table__body-wrapper::-webkit-scrollbar {
    width: 8px; // 横向滚动条
    height: 25px; // 纵向滚动条 必写
    background: #12244d;
  }
  /deep/ .el-table__body-wrapper::-webkit-scrollbar-track {
    border-radius: 10px; /*滚动条的背景区域的圆角*/
    background-color: rgb(18, 36, 77); /*滚动条的背景颜色*/
  }

隔行变色:

javascript 复制代码
//el-table组件添加属性 :stripe="true"
 // 隔行变色(less)
  /deep/ .el-table--striped .el-table__body tr.el-table__row--striped td.el-table__cell {
    background-color: rgba(48, 112, 249, 0.05) !important;
  }

去除鼠标悬停变色效果

javascript 复制代码
//去除鼠标触摸变色效果
 /deep/ .el-table  tbody tr:hover > td{
   background-color: transparent;
 }
相关推荐
老华带你飞3 分钟前
考研论坛平台|考研论坛小程序系统|基于java和微信小程序的考研论坛平台小程序设计与实现(源码+数据库+文档)
java·vue.js·spring boot·考研·小程序·毕设·考研论坛平台小程序
我命由我1234513 分钟前
Word - Word 的 5 种视图(页面视图、阅读视图、Web 版式视图、大纲视图、草稿视图)
ui·word·excel·photoshop·表格·ps·美工
YAY_tyy21 分钟前
基于 Vue3 + VueOffice 的多格式文档预览组件实现(支持 PDF/Word/Excel/PPT)
前端·javascript·vue.js·pdf·word·excel
m0_748461393 小时前
Spring Boot + Vue 项目中使用 Redis 分布式锁案例
vue.js·spring boot·redis
珍珠奶茶爱好者4 小时前
vue二次封装ant-design-vue的table,识别columns中的自定义插槽
前端·javascript·vue.js
Slice_cy4 小时前
深入剖析 Vue 响应式系统:从零实现一个精简版
vue.js
羊羊小栈5 小时前
基于「YOLO目标检测 + 多模态AI分析」的PCB缺陷检测分析系统(vue+flask+数据集+模型训练)
vue.js·人工智能·yolo·目标检测·flask·毕业设计·大作业
晚星star5 小时前
在 Web 前端实现流式 TTS 播放
前端·vue.js
本末倒置1835 小时前
前端面试高频题:18个经典技术难点深度解析与解决方案
前端·vue.js·面试
CodingCos6 小时前
【芯片设计-信号完整性 SI 学习 1.1.1 -- Unit Interval,比特周期】
学习·ui·si 比特周期