如何使表格行固定在顶部 [英] How to make table row fixed at the top

查看:170
本文介绍了如何使表格行固定在顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个没有 th 元素的表格,只有 td 元素在那里。有没有办法让我的第一排固定(标签)。表是这样的

 < table> 
< tr>
< td>名称:< / td>
< td>年龄:< / td>
< / tr>
< tr>
< td> John< / td>
< td> 20< / td>
< / tr>
< tr>
......
< / tr>
< / table>

我想将第一行的Name和Age字段固定为第一行。因此,在滚动期间,标签不会消失。

解决方案

我一直在寻找这个问题的答案一段时间最后我发现了一些非常好用的东西。



秘诀在于这段代码可以在表格中滚动

  thead,tbody,tr,td,th {display:block; } 

但你可以在这里找到一个完整的例子http://jsfiddle.net/T9Bhm/7/

希望它有帮助! :)

I have a table without th elements, Only td elements are there. Is there any way to make My first row fixed(label). The table is like this

<table>
  <tr>
    <td>Name:</td>
    <td>Age:</td>
  </tr>
  <tr>
    <td>John</td>
    <td>20</td>
  </tr>
  <tr>
    ......
  </tr>
</table>

I want to make first row with the fields Name and Age as fixed. So that during the scrolling the labels will not disappear.

解决方案

I've been searching for an answer for this problem for a while and finally I've found something that works very nice.

The secret is in this piece of code that makes the scrolling possible in the table

thead, tbody, tr, td, th { display: block; }

But you can find a full example here http://jsfiddle.net/T9Bhm/7/.

Hope it helps! :)

这篇关于如何使表格行固定在顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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