如何使用 FixedHeaderTable - 需要基本指导

How to use FixedHeaderTable - Need basic guidance

经过大量搜索,我发现了这个插件:Fixed Header Tables。我想我是按照主网站上给出的说明操作的,但我无法使其正常工作。

好吧,我想做一个正常的 table 函数,比如固定顶行和左列。所以我想到了使用这个插件。但最终,它会创建一个阴影 div,但似乎不会滚动或固定到定义的大小。

我也不知道把尺码寄到哪里。这是我到目前为止所拥有的:

$(document).ready(function () {
  $("table").fixedHeaderTable({ footer: true, cloneHeadToFoot: true, fixedColumn: true });
});
* {font-family: Segoe UI;}
body {font-size: 80%;}
table {width: 150px; height: 235px;}
th {text-align: left;}
.fht-table-wrapper {height: 35px;}
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/fixed-header-table/1.3.0/jquery.fixedheadertable.min.js"></script>
<table>
  <thead>
    <tr>
      <th>Sl No</th>
      <th>Name</th>
      <th>Subject</th>
      <th>Marks</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>1</th>
      <td>Praveen</td>
      <td>Communication Disorders</td>
      <td>23</td>
    </tr>
    <tr>
      <th>2</th>
      <td>Bhalmung</td>
      <td>Language Learning</td>
      <td>21</td>
    </tr>
    <tr>
      <th>3</th>
      <td>Vicky</td>
      <td>Computer Engineering</td>
      <td>21</td>
    </tr>
    <tr>
      <th>4</th>
      <td>Alice</td>
      <td>Computer Science</td>
      <td>41</td>
    </tr>
    <tr>
      <th>5</th>
      <td>Carol</td>
      <td>Counselling</td>
      <td>83</td>
    </tr>
    <tr>
      <th>6</th>
      <td>Chuck</td>
      <td>Criminal Justice</td>
      <td>82</td>
    </tr>
    <tr>
      <th>7</th>
      <td>Craig</td>
      <td>Cultural Studies</td>
      <td>93</td>
    </tr>
    <tr>
      <th>8</th>
      <td>Dan</td>
      <td>Ecology</td>
      <td>63</td>
    </tr>
    <tr>
      <th>9</th>
      <td>Erin</td>
      <td>Economics</td>
      <td>26</td>
    </tr>
    <tr>
      <th>10</th>
      <td>Eve</td>
      <td>Education</td>
      <td>22</td>
    </tr>
    <tr>
      <th>11</th>
      <td>Faythe</td>
      <td>Engineering</td>
      <td>52</td>
    </tr>
    <tr>
      <th>12</th>
      <td>Frank</td>
      <td>Engineering Geology</td>
      <td>93</td>
    </tr>
    <tr>
      <th>13</th>
      <td>Mallet</td>
      <td>Engineering Management</td>
      <td>16</td>
    </tr>
    <tr>
      <th>14</th>
      <td>Oscar</td>
      <td>Engineering Mathematics</td>
      <td>57</td>
    </tr>
    <tr>
      <th>15</th>
      <td>Peggy</td>
      <td>English</td>
      <td>5</td>
    </tr>
    <tr>
      <th>16</th>
      <td>Sam</td>
      <td>English Language</td>
      <td>27</td>
    </tr>
    <tr>
      <th>17</th>
      <td>Sybil</td>
      <td>Environmental Science</td>
      <td>61</td>
    </tr>
    <tr>
      <th>18</th>
      <td>Trent</td>
      <td>Ethics</td>
      <td>66</td>
    </tr>
    <tr>
      <th>19</th>
      <td>Walter</td>
      <td>European and European Union Studies</td>
      <td>82</td>
    </tr>
    <tr>
      <th>20</th>
      <td>Wendy</td>
      <td>European Union Studies</td>
      <td>79</td>
    </tr>
  </tbody>
</table>

如果您看到该代码段,则表明它没有包含在 150 px x 235 px 维度中。我哪里错了。

您缺少 defaultTheme.css 文件(或任何主题文件)

$(document).ready(function () {
  $("table").fixedHeaderTable({ footer: true, cloneHeadToFoot: true, fixedColumn: true, height: 300  });
});
* {font-family: Segoe UI;}
body {font-size: 80%;}
table {}
th {text-align: left;}
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/fixed-header-table/1.3.0/jquery.fixedheadertable.min.js"></script>
<link rel="stylesheet" href="http://www.fixedheadertable.com/css/defaultTheme.css" media="screen" />
<table>
  <thead>
    <tr>
      <th>Sl No</th>
      <th>Name</th>
      <th>Subject</th>
      <th>Marks</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>1</th>
      <td>Praveen</td>
      <td>Communication Disorders</td>
      <td>23</td>
    </tr>
    <tr>
      <th>2</th>
      <td>Bhalmung</td>
      <td>Language Learning</td>
      <td>21</td>
    </tr>
    <tr>
      <th>3</th>
      <td>Vicky</td>
      <td>Computer Engineering</td>
      <td>21</td>
    </tr>
    <tr>
      <th>4</th>
      <td>Alice</td>
      <td>Computer Science</td>
      <td>41</td>
    </tr>
    <tr>
      <th>5</th>
      <td>Carol</td>
      <td>Counselling</td>
      <td>83</td>
    </tr>
    <tr>
      <th>6</th>
      <td>Chuck</td>
      <td>Criminal Justice</td>
      <td>82</td>
    </tr>
    <tr>
      <th>7</th>
      <td>Craig</td>
      <td>Cultural Studies</td>
      <td>93</td>
    </tr>
    <tr>
      <th>8</th>
      <td>Dan</td>
      <td>Ecology</td>
      <td>63</td>
    </tr>
    <tr>
      <th>9</th>
      <td>Erin</td>
      <td>Economics</td>
      <td>26</td>
    </tr>
    <tr>
      <th>10</th>
      <td>Eve</td>
      <td>Education</td>
      <td>22</td>
    </tr>
    <tr>
      <th>11</th>
      <td>Faythe</td>
      <td>Engineering</td>
      <td>52</td>
    </tr>
    <tr>
      <th>12</th>
      <td>Frank</td>
      <td>Engineering Geology</td>
      <td>93</td>
    </tr>
    <tr>
      <th>13</th>
      <td>Mallet</td>
      <td>Engineering Management</td>
      <td>16</td>
    </tr>
    <tr>
      <th>14</th>
      <td>Oscar</td>
      <td>Engineering Mathematics</td>
      <td>57</td>
    </tr>
    <tr>
      <th>15</th>
      <td>Peggy</td>
      <td>English</td>
      <td>5</td>
    </tr>
    <tr>
      <th>16</th>
      <td>Sam</td>
      <td>English Language</td>
      <td>27</td>
    </tr>
    <tr>
      <th>17</th>
      <td>Sybil</td>
      <td>Environmental Science</td>
      <td>61</td>
    </tr>
    <tr>
      <th>18</th>
      <td>Trent</td>
      <td>Ethics</td>
      <td>66</td>
    </tr>
    <tr>
      <th>19</th>
      <td>Walter</td>
      <td>European and European Union Studies</td>
      <td>82</td>
    </tr>
    <tr>
      <th>20</th>
      <td>Wendy</td>
      <td>European Union Studies</td>
      <td>79</td>
    </tr>
  </tbody>
</table>

对于那些仍在为这个问题苦苦挣扎的人,请尝试添加 高度 选项

$('#myTable').fixedHeaderTable({ height: 500 });