本项目在开发过程中vue+elementui , 页面中使用了table表格的样式, 需要对原先的样式进行修改,以下是简单的修改样式内容:
项目中某个 html中引用的table表格内容,定义了div的class : device_err :<div class="device_err"><el-table size="small" :header-cell-style="{color: '#ffffff',fontSize: '14px', backgroundColor: '#011946'}":data="tableData"style="width: 98%"height="195">........</el-table><div>
修改table的表头背景 和 字体颜色:
:header-cell-style="{color: '#ffffff',fontSize: '14px', backgroundColor: '#011946'}"
以下是修改el-table表格内容的背景色和边框样式:
/*设置table表格中每行的背景色 及 显示的字体颜色*/
.device_err .el-table tr {background-color: #011946 !important;color: #ffffff;font-weight: bold;
}/*.device_err .el-table--enable-row-transition .el-table__body td, .el-table .cell {background-color: transparent;
}*//* 去除表格线 */
.device_err .el-table__row > td {border: none;
}/* 去除上边框 */
.device_err .el-table th.is-leaf {border: none;
}/* 去除下边框 */
.device_err .el-table::before {height: 0;
}/**
隐藏el-table的header的滚动条*/
.device_err .el-table__header .gutter {background-color: #011946 !important;
}/*隐藏el-table的body的y轴滚动条*/
.device_err .el-table--scrollable-y .el-table__body-wrapper {background-color: #011946 !important;
}.device_err .el-table__body-wrapper::-webkit-scrollbar {width: 0; /*滚动条宽度*/
}/*鼠标滑过td上作用的样式,ie6不支持:hover伪类属性,如果是ie6要写成tr.over样式*/
.device_err .el-table tbody tr:hover > td {background-color: #015476 !important;
}我看到有些百度人说了是使用::deep 和 /deep/ 或者>>>但是我使用了没效果. 苦笑 专业的事情还是需要专业的人来干, 我对前端也是不咋地 .来自一个渺小后端开发的努力.