如何在滚动时使表头静态 [英] How to make a tables header static when scrolling

查看:121
本文介绍了如何在滚动时使表头静态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题已经出现了很多次。当我向下滚动时,我想让表格的标题固定下来,我该怎么做?我的表格代码如下所示:

 < table class =specifictableheight table table-striped> 
< h3> TEST< / h3>
< thead>
< tr>
< th> Places< / th>
< th>点击< / th>
< / tr>
< / thead>
< tbody>
<?php
foreach($ top3overRestaruants as $ key => $ value)
{
?>
< tr class =<?= $ isactive?'alert-success':'';?>>
< td><?= $ key?>< / td>

< td><?= $ value?>< / td>
< / tr>
<?php
}
?>
< / tbody>
< / table>


解决方案

简单:请先制作单独的div, id为那个div ei然后在css规则中制作#head {position:fixed;}
现在解决你的问题。

This issue has appeared many times. I want the table's title to be fixed when I scroll down, how can i do that? My code for the table looks like this

<table class="specifictableheight table table-striped">
<h3>TEST</h3>
<thead>
<tr>
<th>Places</th>
<th>Hits</th>
</tr>
</thead>
<tbody>
<?php
foreach ($top3overRestaruants as $key => $value)
{
?>
<tr class="<?= $isactive ? 'alert-success' : ''; ?>">
<td><?= $key ?></td>

<td><?= $value ?></td>
</tr>
<?php
}
?>
</tbody>
</table>

解决方案

Simple:please first make separate div for head and give id for that div e.i Then make in css rule #head{position:fixed;} Now solve your problem.

这篇关于如何在滚动时使表头静态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆