Element 表格修改边框颜色

本文介绍了如何在前端开发中,使用Element UI库为表格设置头部、单元格和最外层边框的详细步骤。通过配置`header-cell-style`属性实现头部边框,使用`cell-style`方法设置单元格样式,并通过自定义`<style scoped>`标签添加外部边框颜色。这些方法可以帮助开发者精确控制表格的视觉呈现。
摘要由CSDN通过智能技术生成

实现效果 设置表格边框需要分三个部分设置 即头部 单元格以及最外层边框
在这里插入图片描述
头部 设置 使用 :header-cell-style="{color:‘black’,borderColor:‘black’}" 以及 size=“small” 并添加方法:cell-style=“cellStyle”

<el-table border
                      size="small"
                      :data="tableData"
                      :cell-style="cellStyle"
                      height="100%"
                      :highlight-current-row="true"
                      :header-cell-style="{color:'black',borderColor:'black'}"
                      style="margin-top:10px;">
                <el-table-column
                        prop="date"
                        label="日期"
                        width="180"
                        align="center">
                </el-table-column>
                <el-table-column
                        prop="name"
                        label="姓名"
                        width="180"
                        align="center">
                </el-table-column>
                <el-table-column
                        prop="address"
                        label="地址"
                        align="center">
                </el-table-column>
            </el-table>

设置单元格使用 cell-style 方法

methods: {
            //设置单元格背景
            cellStyle({row, column, rowIndex, columnIndex}) {
                return 'height:35px!important; border-color:black!important; color:#000000!important; padding:0px!important; height:40px!important'
            },
        }

设置最外部 只需要添加样式

<style scoped>
    .el-table td, .el-table th.is-leaf,.el-table--border, .el-table--group{
        border-color: black;
    }
    .el-table--border::after, .el-table--group::after, .el-table::before{
        background-color: black;
    }
</style>
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值