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;
 }
相关推荐
岁月宁静2 小时前
深度定制:在 Vue 3.5 应用中集成流式 AI 写作助手的实践
前端·vue.js·人工智能
百锦再4 小时前
Vue Scoped样式混淆问题详解与解决方案
java·前端·javascript·数据库·vue.js·学习·.net
Larry_Yanan4 小时前
QML学习笔记(四十四)QML与C++交互:对QML对象设置objectName
开发语言·c++·笔记·qt·学习·ui·交互
Sheldon一蓑烟雨任平生4 小时前
Vue3 表单输入绑定
vue.js·vue3·v-model·vue3 表单输入绑定·表单输入绑定·input和change区别·vue3 双向数据绑定
偶尔的鼠标人6 小时前
Avalonia 的命令基类和通知基类备份
ui·mvvm·avalonia
YUELEI1186 小时前
Vue 安装依赖的集合和小知识
javascript·vue.js·ecmascript
前端付豪8 小时前
万事从 todolist 开始
前端·vue.js·前端框架
Larry_Yanan8 小时前
QML学习笔记(四十五)QML与C++交互:信号槽的双向实现
c++·笔记·qt·学习·ui·交互
华仔啊9 小时前
别再纠结Pinia和Vuex了!一篇文章彻底搞懂区别与选择
前端·vue.js
月弦笙音10 小时前
【Vue3】Keep-Alive 深度解析
前端·vue.js·源码阅读