el-table和分頁外掛修改樣式以及解決表頭和內容歪掉的問題
阿新 • • 發佈:2020-08-28
1、可以通過el-table的屬性修改樣式
<el-pagination background :page-sizes="[10, 20, 30, 40,50,60,70,80,90,100]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total" @current-change="selectZwrmc" @size-change="handleSizeChange":current-page.sync="currentPage" id="el-pagin" small />
<el-table :data="items" ref="Table" highlight-current-row @selection-change="selectItem" :max-height="maxHeight" :header-cell-style="{'text-align':'center'}":row-style="rowStyle" id="sqTable" >
header-cell-style修改表頭樣式,可以直接寫樣式如:header-cell-style="{'text-align':'center'}",可以繫結方法,返回樣式;
row-style修改行樣式,和上面修改表頭樣式一樣,我這裡繫結的方法是rowStyle,預設傳入當前行和行的索引
rowStyle({ row, rowIndex }) { return { height: "25px", padding:"0px 0px 0px 0px", }; },
2、可以通過style修改樣式,需要注意的是表頭的下邊框線要用0.5px才能顯示如border-bottom: 0.5px solid #c0c4cc;我試過1px是不可以的。>>>穿透挺好用的。
有時候內容和表頭會歪掉,
.el-table >>> th.gutter { display: table-cell !important; }
用上面樣式可以調好。
下面用到id選擇器都是我自己加的,類選擇器是elementUI自帶的
<style scoped > .el-table >>> th { background-color: #e4e7ed; border-top: 1px solid #c0c4cc; border-right: 1px solid #c0c4cc; border-bottom: 0.5px solid #c0c4cc; } .el-table >>> td { border-right: 1px solid #c0c4cc; border-bottom: 0.5px solid #c0c4cc; } #sqTable >>> td { padding: 0px; font-size: 12px; } #sqTable >>> th { padding: 0px; height: 30px; } #el-pagin >>> * { font-size: 12px; } .el-table >>> th.gutter { display: table-cell !important; } #sqTable >>> thead .el-table-column--selection { border-left: 1px solid #c0c4cc; } #sqTable >>> tbody .el-table-column--selection { border-left: 1px solid #c0c4cc; } #sqTable >>> tbody td { border-right: 1px solid #c0c4cc; border-bottom: 1px solid #c0c4cc; } </style>