原生table实现thead固定,tbody高度超出时滚动的实现方法

在这里插入图片描述

<div class="table-wrapper">
      <table cellpadding="0" cellspacing="0">
          <thead>
            <th >序号</th>
            <th *ngFor="let item of columns; let i = index">{{item.title}}</th>
            <th >操作</th>
          </thead>
              <tbody>             
                  <tr *ngFor="let ritem of this.resultList; let i = index">
                   <td >{{i+1}}</td>
                   <td [title]="ritem[citem.key]"*ngFor="let citem of columns; let i = index" >{{ritem[citem.key]}}</td>
                   <td><a class="more_btn" (click)="delete(ritem)">删除</a></td>
                 </tr>
               </tbody>
      </table>
  </div>
.table-wrapper {
    table {
       table-layout: fixed;
       width: 100%;
       text-align: left;
       font-size: 10px;
       box-shadow: 0px 0px 2px 0px #ccc;
        thead {
            display: flex;
            justify-content: space-between;
            background-color: #f2f6fc;
            th {
              font-size: 12px;
              font-weight: 600;
              color: #4c4c4c;
              font-weight: 600;
              padding: 8.5px 1.2rem;
              border-radius: 3px 3px 0px 0px;
              height: 100%;
              opacity: 0.8;
              text-align: left;
            }
          }
        tbody{
            display: inline-block;
            width: 100%;
            overflow: auto;
            max-height: 35.625rem;
            background-color: #fff;
            tr {
                border-bottom: 1px solid rgba(0, 0, 0, 0.08);
                display: flex;
                justify-content: space-between;
                width: 100%;
                td {
                    display: inline-block;
                    color: #606266;
                    padding: 8.5px 1.2rem;
                    font-size: 12px;
                    font-weight: 400;
                    text-align: left;
                    white-space:nowrap;
                    overflow:hidden;
                    text-overflow:ellipsis;
                  }
              }
        
            
        }
    }
} 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值