【发布时间】:2014-07-01 00:17:18
【问题描述】:
我有一个如下所示的表格,并且正在尝试创建一个固定的标题,这样无论我向下滚动多少,标题始终对用户可见。我对网页设计没有太多经验,所以想知道如何使用 css / javascript 来做到这一点?我猜我首先需要在<th> 标签周围放置一个<thead> 标签以使它们成为一个实体?尽管这必须使用 javascript 来完成,因为 html 是使用我无法编辑的外部宏生成的。非常感谢任何帮助!
<table id="TBL1399802283490" class="confluenceTable">
<tbody>
<tr>
<th class="confluenceTh" style="cursor: pointer;">Server Name </th>
<th class="confluenceTh" title="null" style="cursor: pointer;">Network Zone </th>
<th class="confluenceTh" title="null" style="cursor: pointer;">Operational Status </th>
</tr>
<td class="confluenceTd"><div style="left:1em;right:1em"> w264521f </div> </td>
<td class="confluenceTd"><div style="left:1em;right:1em"> GREEN </div> </td>
<td class="confluenceTd"><div style="left:1em;right:1em"> READY </div> </td>
<tr>
</tr>
</tbody>
</table>
请注意,列的宽度不是固定的。它们需要是可变的,因为数据不是恒定的。
【问题讨论】:
-
@SW4 不是真的,我在问如何在Javascript中获取
<thead>标签 -
提问前请使用google.com。
-
@Anonymous 该答案使用 Jquery,我无法使用。只有纯 Javascript。
-
@AkshaiShah 无论哪种方式,在谷歌上搜索时至少有三个不同的问题问同样的问题。
标签: javascript html css confluence