场景
当数据条数过多时,鼠标下滑浏览表格数据,预期表头一直在表格最上方,不随鼠标滑动而被滑出屏幕
实现步骤
①引入所需css和js。
下载链接:https://download.youkuaiyun.com/download/Peacock__/12251877
<!--冻结表头所需css-->
<link href="../static/css/bootstrap-table-fixed-header.css" rel="stylesheet"/>
<!--冻结表头所需js-->
<script src="/js/bootstrap-table-fixed-header.js" type="text/javascript"></script>
②bootstrap-table表格放到div中,给div加个松开鼠标时执行的事件来模拟模拟鼠标滚动事件,以实现横向滚动条的移动,表头跟数据对应。并给表格添加class=“table table-striped table-fixed-header”
<!--bootstrap-table表格放到DIV中,加个松开鼠标时