如果我明白你在找什么;我不久前做过类似的事情。
Html可能看起来像这样。
<table border="1" id="header">
<tr>
<th></th>
<th></th>
</tr>
</table>
<div id="tableData">
<table border="1" id="table">
<td></td>
<td></td>
</table>
</div>
CSS
#tableData {
overflow: scroll;
overflow-x:hidden;
height: 190px;
border-bottom: 1px solid #B5B3B3;
width: 940px;
}
JavaScript才能确保头与您可能需要做出一些调整表数据
$("#tableData").height(190);
$("#tableData").width(940);
for(var i=1;i<8;i++){
if($("#header th:nth-child("+i.toString()+")").width() >= $("#table td:nth-child("+i.toString()+")").width())
$("#table td:nth-child("+i.toString()+")").width($("#header th:nth-child("+i.toString()+")").width());
else
$("#header th:nth-child("+i.toString()+")").width($("#table td:nth-child("+i.toString()+")").width());
}
$("#tableData").width($("#table").width()+20);
if($("#table").height() <= $("#tableData").height())
$("#tableData").height($("#table").height());
对齐,但是这是一个解决方案。我的变量需要覆盖每一列,在我的例子中它可以用于7列。
我认为你自己的建议是要走的路....你所描述的问题有点不清楚......也许你可以添加一些示例代码或示例地址,我们可以看看? –
请参阅以下链接:http://stackoverflow.com/questions/296020/how-can-i-lock-the-first-row-and-first-column-of-a-table-when-scrolling-possiblely http: //www.cubido.at/blogs/Lists/Posts/Post.aspx?ID=1259 – Brij
Thanks..but的链接来解决不工作.. – Neo