做一个随着滚动条滚动显示的浮动的表头

本文介绍了一种使用JavaScript实现的滚动监听功能,当滚动条接近特定元素时显示一个固定位置的表格。通过jQuery简化DOM操作,并配合CSS进行样式设置。

js

     $(window).scroll(function(){
    var this_scrollTop = $(this).scrollTop();
        // その他画面
        if($("#search-list").offset().top - this_scrollTop  < 10){
    $("#newTable").show();
    }else{
    $("#newTable").hide();
    }

    });

css

    <style type="text/css">
#newTable {
position: fixed;
z-index: 1;
margin-right:24px;
margin-top:-7px;
}
#newTable table {
table-layout:fixed;
border-collapse: separate !important;
border-bottom-style: hidden;
}
#newTable table tr {
background-color: white;
}
#newTable table th {
border-bottom-width: 3px !important;
}

</style>

jsp

    <div class="dataTable_wrapper"id="newTable" style="display:none;">
<table class="table table-striped table-bordered table-hover serch-result"
style="text-align: left; margin-top: 4px !important; table-layout: fixed;">
<thead>
<tr>
<th style="display: none;"></th>
<th class="text-center" style="width:8%; vertical-align: middle;">セット<br>番号</th>
<th class="text-center" style="width:8%; vertical-align: middle;">記号</th>
<th class="text-center" style="width:8%; vertical-align: middle;">グループ<br>記号</th>
<th class="text-center" style="width:16%; vertical-align: middle;">図書名称</th>
<th class="text-center" style="width:7%; vertical-align: middle;">数量</th>
<th class="text-center" style="width:15%; vertical-align: middle;">保管事業所</th>
<th class="text-center" style="width:15%; vertical-align: middle;">保管場所</th>
<th class="text-center" style="width:15%; vertical-align: middle;">備考</th>
<th style="display: none;"></th>
<th class="text-center" style="width:8%; vertical-align: middle;">電気・機械<br>区分</th>
<th style="display: none;"></th>
</tr>
</thead>
</table>
</div>

    

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值