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;
 }
相关推荐
Cobyte12 分钟前
17. Vue3 业务组件库按需加载的实现原理
前端·javascript·vue.js
码上成长1 小时前
Vue Router 3 升级 4:写法、坑点、兼容一次讲透
前端·javascript·vue.js
abiao19813 小时前
如何在 VSCode 中创建 Vue 项目
ide·vue.js·vscode
西西西西胡萝卜鸡3 小时前
虚拟列表(Virtual List)组件实现与优化铁臂猿版(简易版)
前端·vue.js
宇余3 小时前
Unibest:新一代uni-app工程化最佳实践指南
前端·vue.js
性野喜悲3 小时前
ts+uniapp小程序时间日期选择框(分开选择)
前端·javascript·vue.js
lcc1875 小时前
Vue 内置指令
前端·vue.js
JIngJaneIL7 小时前
就业|高校就业|基于ssm+vue的高校就业信息系统的设计与实现(源码+数据库+文档)
java·前端·数据库·vue.js·spring boot·毕设·高校就业
一 乐7 小时前
社区互助|社区交易|基于springboot+vue的社区互助交易系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·后端·小区互助系统
shmily麻瓜小菜鸡8 小时前
Element Plus 的 <el-table> 怎么点击请求后端接口 tableData 进行排序而不是网络断开之后还可以自己排序
前端·javascript·vue.js