Element中table组件(el-table)右侧滚动条空白占位gutter处理
当我设置了max-height,就会在表格右侧出现一列空白的占位导致表格内容没对齐
<el-table border max-height="56" header-cell-class-name="header_class" stripe size="small"style="width: 100%">
<el-table-column fixed="left" prop="monitorTime" label="监测时间" :formatter="formatDateTime"> </el-table-column><el-table-column fixed="left" label="水质等级"></el-table-column><el-table-column fixed="left"><template slot="header"><div style="line-height: 1.5; text-align: center;">水温<br>℃<br></div></template></el-table-column><el-table-column fixed="left"><template slot="header"><div style="line-height: 1.5; text-align: center;">PH<br>无量纲<br></div></template></el-table-column><el-table-column fixed="left"><template slot="header"><div style="line-height: 1.5; text-align: center;">溶解氧<br>mg/L<br></div></template></el-table-column><el-table-column fixed="left"><template slot="header"><div style="line-height: 1.5; text-align: center;">电导率<br>μS/cm<br></div></template></el-table-column><el-table-column fixed="left"><template slot="header"><div style="line-height: 1.5; text-align: center;">浑浊度<br>NTU<br></div></template></el-table-column><el-table-column fixed="left"><template slot="header"><div style="line-height: 1.5; text-align: center;">高锰酸盐指数<br>mg/L<br></div></template></el-table-column><el-table-column fixed="left"><template slot="header"><div style="line-height: 1.5; text-align: center;">氨氮<br>mg/L<br></div></template></el-table-column><el-table-column fixed="left"><template slot="header"><div style="line-height: 1.5; text-align: center;">总磷<br>mg/L<br></div></template></el-table-column><el-table-column fixed="left"><template slot="header"><div style="line-height: 1.5; text-align: center;">总氮<br>mg/L<br></div></template></el-table-column></el-table>
element的table组件有一个max-height参数可以设置表格组件的最大高度。
如果数据过多,在最大高度内展示不开,就会自动加一个滚动条,进行滚动展示。
如果数据很少,没有达到最大高度,那么右侧不应该有滚动条,和一切干扰列。
但是当我设置了max-height ,且我这个地方没有达到最大高度,就会在表格右侧出现一列空白的占位,这样比较丑。
解决方法1:
不设置max-height参数。
解决方法2:
有特定的需求需要保留max-height参数,调整max-height的高度
<el-table border max-height="60" header-cell-class-name="header_class" stripe size="small"style="width: 100%"></el-table>
解决方法3:
效果图:
使用解决方法2