table中的th、td边框失效

问题重现:

table,设置边框1px solid #ddd,根据th、td,设置不同边框

谷歌浏览器正常,火狐浏览器表格边框,均只显示左、上边框


解决办法:

   table, tr, td, th, thead, tbody {
     position: static;
}


解决过程:

走了很多弯路

1)第一反应是width不够,于是尝试给元素增加width。无效

2)发现,如果设置极端些,比如border-right-width:20px,会显示边框,但是在td右侧只有一条线,width为20排序,高度为1px,于是尝试给元素增加height、line-height。无效

3)border-collapse属性。设置了border-collapse:collapse。无效

4)position:relative。搜到博客《td标签上的position:relative属性td边框在各浏览器中的兼容性问题》(此为转载,未标明原作者http://blog.sina.com.cn/s/blog_6b2fcbbc0102w52a.html)。据此改动css代码。成功。



参考:

[1]. 陆远. RE2007: 各浏览器解决表格边框冲突的方式存在差异[EB/OL]. http://www.w3help.org/zh-cn/causes/RE2007.

[2]. 陆远. BX3006: 各浏览器对 TABLE、TH、TD 元素的 bordercolor 属性的处理有差异[EB/OL]. http://www.w3help.org/zh-cn/causes/BX3006.

<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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值