element ui table去掉边框和背景颜色以及滚动条修改高亮和字体

本文详细介绍如何修改ElementUI组件样式,包括去除背景颜色、边框线,自定义滚动条样式,调整高亮效果及头部字体颜色,帮助开发者实现个性化界面设计。

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

在使用element ui时,我们总是需要把他的样式修改为自己的样式,
如下图:
修改之前:
在这里插入图片描述
修改之后:
在这里插入图片描述

去掉背景颜色

    .el-table, .el-table__expanded-cell {
        background-color: transparent!important;
    }
    
    .el-table th, .el-table tr {
       border: 0!important;
        background-color: transparent!important;
    }

去掉边框线

     .el-table--border tr,td{
       border: none!important;
    }
    .el-table::before{
      height:0;
    }

修改滚动条样式

    /*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
    ::-webkit-scrollbar {
    width: 7px; /*滚动条宽度*/
    height: 7px; /*滚动条高度*/
    background-color: rgb(0, 12, 46);
    }

    /*定义滑块 内阴影+圆角*/
    ::-webkit-scrollbar-thumb {
    -webkit-box-shadow: inset 0 0 6px rgba(216, 39, 39, 0.3);
    background-color: rgb(0, 12, 46); /*滚动条的背景颜色*/
    }

修改高亮

.el-table--enable-row-hover .el-table__body tr:hover>td{
    background-color:rgb(0, 12, 46) !important;
    }

修改头部字体

 .el-table thead{
          color:rgba(32,253,250,0.7)!important;
    }
<template> </div> <el-table :data=“tableData” border style=“width: 100%” class=“el-table”> <el-table-column fixed prop=“date” label=“日期” width=“150”> </el-table-column> <el-table-column prop=“name” label=“姓名” width=“120”> </el-table-column> <el-table-column prop=“province” label=“省份” width=“120”> </el-table-column> <el-table-column prop=“city” label=“市区” width=“120”> </el-table-column> <el-table-column prop=“address” label=“地址” width=“300”> </el-table-column> <el-table-column prop=“zip” label=“邮编” width=“120”> </el-table-column> <el-table-column fixed=“right” label=“操作” width=“100”> <template slot-scope=“scope”> <el-button @click=“handleClick(scope.row)” type=“text” size=“small”>查看</el-button> <el-button type=“text” size=“small”>编辑</el-button> </template> </el-table-column> </el-table> </div> </template> <script> export default { data() { return { searchKeyword: ‘’,// 搜索关键词 tableData: [{ date: ‘2016-05-02’, name: ‘王小虎’, province: ‘上海’, city: ‘普陀区’, address: ‘上海市普陀区金沙江路 1518 弄’, zip: 200333 }, { date: ‘2016-05-04’, name: ‘王小虎’, province: ‘上海’, city: ‘普陀区’, address: ‘上海市普陀区金沙江路 1517 弄’, zip: 200333 }, { date: ‘2016-05-01’, name: ‘王小虎’, province: ‘上海’, city: ‘普陀区’, address: ‘上海市普陀区金沙江路 1519 弄’, zip: 200333 }, { date: ‘2016-05-03’, name: ‘王小虎’, province: ‘上海’, city: ‘普陀区’, address: ‘上海市普陀区金沙江路 1516 弄’, zip: 200333 }] } }, methods: { handleSearch() { // 执行搜索逻辑 console.log(‘搜索内容:’, this.searchKeyword); // 实际开发中这里调用接口,传递 searchKeyword 进行数据查询 }, handleClick(row) { console.log(row); } } }; </script> <style scoped lang=“scss”> } //底部背景 .el-table { background: transparent !important; color: white; } //表头背景 ::v-deep .el-table th{ background: #245c8d !important ; height: 10px !important; } //行内背景 ::v-deep .el-table tr{ background: #245c8d !important ; height: 10px !important; } //表头字体颜色 ::v-deep .el-table thead{ color: white; } ::v-depp .el-table td,building-top .el-table th.is-leaf{ border-bottom: 2px solid #2C82BE !important; } // ::v-deep .el-table–enable-row-hover .el-table__body tr:hover>td{ // background-color: #245c8d !important; // } /* 修改鼠标悬浮效果 / .el-table tbody tr:hover > td { background-color: #000000 !important; / 新的高亮颜色 / cursor: pointer; / 更改光标形状 */ } </style>边框颜色,高度宽度、hover样式修改了但是无变化
03-26
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值