【发布时间】:2014-06-07 18:48:36
【问题描述】:
我有类似的东西
<table>
<thead>
<tr class="class1"><td>Col 11</td><td>Col 12</td><td>Col 13</td></tr> //Row 1
<tr class="class2"><td>Col 21</td><td>Col 22</td><td>Col 23</td></tr> //Row 2
</thead>
<tbody>
<tr><td>D 11</td><td>D 12</td><td>D 13</td></tr>
<tr><td>D 21</td><td>D 22</td><td>D 23</td></tr>
.
.
<tr><td>D n1</td><td>D n2</td><td>D n3</td></tr>
</tbody>
</table>
当 tbody 中有更多行时,我想让第 1 行和第 2 行粘在页面顶部,我正在使用以下脚本,
var c1 = $(".class1");
var c2 = $(".class2");
if(st > 315) {
c1.css({
position: "fixed",
top: "110px"
});
c2.css({
position: "fixed",
top: "145px"
});
}
else {
c1.css({
position: "",
top: "",
});
c2.css({
position: "",
top: "",
});
}
当两行到达 position:fixed 时,tboby 内容会缩小(好像 thead 和 tbody 是单独的表格元素)
我希望在整个过程中修复 td。 如何解决这个问题? :(
提前致谢。
【问题讨论】:
-
你能做一个小提琴吗?
标签: javascript css html