简单的自定义固定表头thead tbody滚动 第二版

固定表头thead  ,之前在网上看到的各种方法,感觉都不是我想要的结果,自己尝试写了一下,当然,网上也有插件可以用,自己百度一下,引入了插件后,一行代码就搞定;

1.效果展示
 .simple-table th {
    color: #3A3F46;
    background: #eef2fa;
    border-right: 1px solid #e7ecf1;
}
 模拟的表头多一个th作为数据量大时的最右侧的tbody的滚动宽度
 <div class="table-outer">
                        <!-- 模拟固定表头 多一个th作为数据量大时的最右侧的tbody的滚动宽度-->
                    <div   style="height:36px;overflow-y: auto;overflow-x: hidden;" >
                     <table class="simple-table" >
                         <colgroup>
                             <col width="50px" />
                             <col width="170px" />
                             <col width="110px" />
                             <col width="130px" />
                             <col width="130px" />
                             <col width="90px" />
                             <col width="130px" />
                             <col width="90px" />
                             <col width="130px" />
                             <col width="15px" />
                         </colgroup>
                            <thead >
                             <tr  >
                                <th > 序号 </th>
                                <th >测试</th>
                                <th >测试测试1</th>
                                <th >测试正常率</th>
                                <th >测试响应率</th>
                                <th >测试次数</th>
                                <th >测试成功次数</th>
                                <th >测试次数</th>
                                <th >测试成功次数</th>
                                <th ></th>
                            </tr>
                            </thead>
                     </table>
                    </div>
    <!-- 实际表结构 -->
<div   style="height:250px;overflow-y: auto;overflow-x: hidden;" >
        <table class="simple-table" id="xtbb-list">
        <colgroup>
    <col width="50px" />
    <col width="170px" />
    <col width="110px" />
    <col width="130px" />
    <col width="130px" />
    <col width="90px" />
    <col width="130px" />
    <col width="90px" />
    <col width="130px" />
</colgroup>
   <!--  隐藏实际表thead -->
<thead style="display:none;" >
<tr  >
   <th > 序号 </th>
            <th >测试</th>
            <th >测试测试1</th>
            <th >测试正常率</th>
            <th >测试响应率</th>
            <th >测试次数</th>
            <th >测试成功次数</th>
            <th >测试次数</th>
            <th >测试成功次数</th>
</tr>
</thead>
<tbody > <!-- tbody部分我用的是前台模板引擎加载的 -->
<%for(var j = 0; j < 10; j++) {%>
<tr> 
<td></td>
 <td></td>
 <td></td> 
<td></td>
 <td></td>
 <td></td>
 <td></td>
 <td></td>
 <td></td>
</tr>
<%}%>
</tbody> 
</table>
</div>
!!!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值