HTML中怎么把表头固定

 时间:2026-02-12 22:00:10

1、准备:先去官方网站下载插件包,datatable需要jQuery,所以还要提前下载jQuery插件。

HTML中怎么把表头固定

2、引入文件:

<link rel="stylesheet" type="text/css" href="datatables.css">

  <script type="text/javascript" language="javascript" src="jquery-1.12.4"></script>

  <script type="text/javascript" language="javascript" src="datatables.js"></script>

3、javascript代码:

<script type="text/javascript" class="init">

$(document).ready(function() {

$('#example').DataTable( {

"scrollY":        "300px",

"scrollCollapse": true,

"paging":         false

} );

} );

</script>

4、table部分代码:

 <table id="example" class="display">

<thead>

<tr>

<th>学号</th>

<th>姓名</th>

<th>班级</th>

<th>科目</th>

<th>分数</th>

<th>排名</th>

</tr>

</thead>

<tbody>

<tr>

<td>1</td>

<td>小明</td>

<td>三年级一班</td>

<td>数学</td>

<td>90</td>

<td>9</td>

</tr>

......

5、效果如图所示

HTML中怎么把表头固定

  • vf6.0设置常用的组合框控件属性
  • 怎么制作纸张卷页卷边的效果 PS
  • 微信红包祝福语8字考上大学
  • 怎么把另外一个物体附加到一起
  • 易语言端口流程控制如果真如何使用
  • 热门搜索
    was怎么读 机票怎么取 peach怎么读 电脑风扇声音大怎么办 雅士利奶粉怎么样 我的世界铁砧怎么用 年终奖怎么算 淘宝店铺怎么装修 烧心怎么办 血小板低怎么治疗