element-plus固定最后两行数据不动

在el-table中添加class=‘fixed-nth-last-child’

<el-table
  class="fixed-nth-last-child"
></el-table>

css样式如下:

为了让表格呈现滚动效果,必须设定table-layout:fixed 并且给与表格宽度

要注意的是当position : sticky应用于table,只能作用于<th>和<td>,并且一定要定义目标位置 left / right / top / bottom 才会出现固定效果!

复制代码
// 修改倒数第二行的样式
:deep .fixed-nth-last-child tr:nth-last-child(2) {
  position: sticky; // 固定表格则需要使用到 position : sticky 的设定
  table-layout: fixed;
  bottom: 36px; // 设置的列表行高
  z-index: 2; // 和列表滚动条保持一致,高了会遮盖滚动条
}
// 修改倒数第一行的样式
:deep .fixed-nth-last-child tr:nth-last-child(1) {
  position: sticky;
  table-layout: fixed;
  bottom: 0;
  z-index: 2;
}
复制代码

 

posted @   代码改变世界是吧  阅读(539)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示