使用 colgroup标签实现表头表尾固定,中间内容自适应

话不多说,直接上代码:

 <table style="width: 99%;borderTop:1px solid #000;borderLeft:1px solid #000">
            <colgroup>
                <col width='3%'>
                <col width='8%'>
                <col width='8%'>
                <col width='8%'>
                <col width='7%'>
                <col width='8%'>
                <col width='10'>
                <col width='5%'>
                <col width='5%'>
                <col width='5%'>
                <col width='5%'>
                <col width='5%'>
                <col width='5%'>
                <col width='5%'>
                <col width='5%'>
                <col width='8%'>
            </colgroup>
            <thead style="height: 30px;font-weight: bold;" id="header">
              <tr>
                <th >序号</th>
                <th >合同号</th>
                <th >计划单号</th>
                <th >车号</th>
                <th >产线</th>
                <th >牌号</th>
                <th >规格</th>
                <th >件数</th>
                <th >拟报结算量</th>
                <th >结算基准价</th>
                <th >下浮</th>
                <th >钢种加价</th>
                <th >规格加价</th>
                <th >其他加价</th>
                <th >拟报结算价</th>
                <th >金额</th>
              </tr>
            </thead>
          </table>
          <!-- 中间表格 -->
          <div style="width:100%;height:500px;overflow:auto">
            <table border="1" style="width:100%;borderTop:0">
              <colgroup>
                <col width='3%'>
                <col width='8%'>
                <col width='8%'>
                <col width='8%'>
                <col width='7%'>
                <col width='8%'>
                <col width='10'>
                <col width='5%'>
                <col width='5%'>
                <col width='5%'>
                <col width='5%'>
                <col width='5%'>
                <col width='5%'>
                <col width='5%'>
                <col width='5%'>
                <col width='8%'>
              </colgroup>
              <tbody id="tbody">
                <tr v-for="(item) in lineData" :key="item.id" style="height: 25px">
                  <td>{{ item.index }}</td>
                  <td>{{ item.contract_no }}</td>
                  <td>{{ item.plan_no }}</td>
                  <td>{{ item.car_no }}</td>
                  <td>{{ item.product_line }}</td>
                  <td>{{ item.steel_no }}</td>
                  <td>{{ item.spec }}</td>
                  <td>{{ item.number }}</td>
                  <td>{{ item.accounts_weight }}</td>
                  <td @click="pageto(item.online_amount,item.price_id)" :class="{'style':item.online_amount !== null && item.index !== '合计'}">{{ item.online_amount }}</td>
                  <td>{{ item.low }}</td>
                  <td>{{ item.steel_amount }}</td>
                  <td>{{ item.spec_amount }}</td>
                  <td>{{ item.other_amount }}</td>
                  <td @click="pageto(item.accounts_amount,item.price_id)" :class="{'style':item.accounts_amount !== null && item.index !== '合计'}">{{ item.accounts_amount }}</td>
                  <td>{{ item.amount }}</td>
                </tr>
              </tbody>
            </table>
          </div>
          <!-- 尾部表格 -->
          <table style="width: 99%;borderTop:1px solid #000;borderLeft:1px solid #000">
            <colgroup>
                <col width='3%'>
                <col width='8%'>
                <col width='8%'>
                <col width='8%'>
                <col width='7%'>
                <col width='8%'>
                <col width='10'>
                <col width='5%'>
                <col width='5%'>
                <col width='5%'>
                <col width='5%'>
                <col width='5%'>
                <col width='5%'>
                <col width='5%'>
                <col width='5%'>
                <col width='8%'>
            </colgroup>
            <thead style="height: 30px;font-weight: bold;" id="header">
              <tr>
                <th>合计</th>
                <th></th>
                <th></th>
                <th></th>
                <th></th>
                <th></th>
                <th></th>
                <th></th>
                <th>{{ accounts_weight }}</th>
                <th>{{ online_amount }}</th>
                <th></th>
                <th></th>
                <th></th>
                <th></th>
                <th>{{ accounts_amount }}</th>
                <th>{{ amount }}</th>
              </tr>
            </thead>
          </table>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值