做个笔记,记录一下表格的设置,尤其是滑动条的设置
用一个card来装表格,然后给card设置样式使其出现在页面右上方,然后设置z-index属性使其位于页面最上方,然后设置虚化程度。
<el-card class="texttable" :body-style="{ padding: '0px' }" style="width: 600px;">
<el-table
:data="datas"
max-height="400"
style="background-color: #545c64;border: 0;margin: 0;"
:header-cell-style="{'background-color': '#545c64','text-align':'center','color':'#fff'}"
:cell-style="{'background-color': '#545c64','text-align': 'center','color':'#fff'}"
>
<!-- 表格内容 -->
</el-table>
</el-card>
<style scoped>
/* 定位,置顶,虚化程度设置为0.85 */
.texttable {
position: absolute;
right: 100px;
top: 100px;
z-index: 999;
opacity: 0.85;
}
/* 去除底部的白线 */
.el-table::before {
height: 0;
}
/* 设置滚动快样式 */
::v-deep .el-table__body-wrapper::-webkit-scrollbar-thumb {
background-color: #353a3f;
border-radius: 3px;
}
/* 设置滚动条样式 */
::v-deep .el-table__body-wrapper::-webkit-scrollbar {
width: 6px;
height: 6px;
}
/* 隐藏表格头部多余的空白列 */
::v-deep .el-table th.gutter{
display: none;
width:0px
}
/* 隐藏表格主题的多余空白列 */
::v-deep .el-table colgroup col[name='gutter']{
display: none;
width: 0;
}
/* 强制表格主体填充整个宽度 */
::v-deep .el-table__body{
width: 100% !important;
}
</style>
最后效果如下:
在el-table里特意没加表格线,因为这里设置完滚动条后会出现表格线对不齐的情况,所以去掉反而更美观,所以就没加了。