Tbody滚动条问题
我想修改以下代码,以便 tbody 可以有一个滚动条,而无需移动 thead:
<table class="sortable">
<thead border="0" cellspacing="0" cellpadding="2" align="left" style="position:relative; bottom:-3px; left:0px;">
<tr>
<%
For i = 0 to Ubound(hdVals)
if i = 0 then
response.Write "<td class=""symbollng"" valign=""bottom"" style=""border-right:0px; border-left:0px;"">" & hdVals(i) & "</td>" & vbnewline
elseif i = 1 then
response.Write "<td class=""close-hd"" valign=""bottom"">" & hdVals(i) & "</td>" & vbnewline
else
dstrVals(i-2,0) = hdVals(i)
response.Write "<td class=""col-hd-wd"" valign=""bottom"">" & hdVals(i) & "</td>" & vbnewline
end if
Next
%>
</tr>
</thead>
<tbody class="scrollContent">
<%
EO = "odd"
For i = 1 to Ubound(tmpRows)-1
if EO = "odd" then
response.Write "<tr class=""grey"">" & vbnewline
else
response.Write "<tr>" & vbnewline
end if
tmpRowVals1 = split(tmpRows(i),"=")
tmpRowVals = split(tmpRowVals1(1),":")
For j = 0 to Ubound(tmpRowVals)
if j = 0 then
response.Write "<td class=""symbollng""><span title=""" & tmpRowVals(j) & """>" & tmpRowVals(j) & "</span></td>" & vbnewline
elseif j = 1 then
if trim(tmpRowVals(j)) = "" then
response.Write "<td class=""close""> </td>" & vbnewline
else
response.Write "<td class=""close""><span title=""" & tmpRowVals(j) & """>" & tmpRowVals(j) & "</span></td>" & vbnewline
end if
else
Call addToDistChart(j-2,tmpRowVals(j))
gTime = hdVals(j)
response.Write getCellColorWithClick(curlv(tmpRowVals(j)),tmpRowVals(0),gSec,gChar,gTime)
end if
Next
response.Write "</tr>" & vbnewline
if EO = "odd" then
EO = "even"
else
EO = "odd"
end if
Next
%>
</tbody>
</table>
这是迄今为止我为表格设计的图片:
希望这是我代码中的一个小编辑,因为处理表格一直很痛苦:(
I have the following code that I want to modify so that the tbody can have a scrollbar without the thead moving:
<table class="sortable">
<thead border="0" cellspacing="0" cellpadding="2" align="left" style="position:relative; bottom:-3px; left:0px;">
<tr>
<%
For i = 0 to Ubound(hdVals)
if i = 0 then
response.Write "<td class=""symbollng"" valign=""bottom"" style=""border-right:0px; border-left:0px;"">" & hdVals(i) & "</td>" & vbnewline
elseif i = 1 then
response.Write "<td class=""close-hd"" valign=""bottom"">" & hdVals(i) & "</td>" & vbnewline
else
dstrVals(i-2,0) = hdVals(i)
response.Write "<td class=""col-hd-wd"" valign=""bottom"">" & hdVals(i) & "</td>" & vbnewline
end if
Next
%>
</tr>
</thead>
<tbody class="scrollContent">
<%
EO = "odd"
For i = 1 to Ubound(tmpRows)-1
if EO = "odd" then
response.Write "<tr class=""grey"">" & vbnewline
else
response.Write "<tr>" & vbnewline
end if
tmpRowVals1 = split(tmpRows(i),"=")
tmpRowVals = split(tmpRowVals1(1),":")
For j = 0 to Ubound(tmpRowVals)
if j = 0 then
response.Write "<td class=""symbollng""><span title=""" & tmpRowVals(j) & """>" & tmpRowVals(j) & "</span></td>" & vbnewline
elseif j = 1 then
if trim(tmpRowVals(j)) = "" then
response.Write "<td class=""close""> </td>" & vbnewline
else
response.Write "<td class=""close""><span title=""" & tmpRowVals(j) & """>" & tmpRowVals(j) & "</span></td>" & vbnewline
end if
else
Call addToDistChart(j-2,tmpRowVals(j))
gTime = hdVals(j)
response.Write getCellColorWithClick(curlv(tmpRowVals(j)),tmpRowVals(0),gSec,gChar,gTime)
end if
Next
response.Write "</tr>" & vbnewline
if EO = "odd" then
EO = "even"
else
EO = "odd"
end if
Next
%>
</tbody>
</table>
Here is a picture of the design I have so far for the table:
Hopefully its a small edit in my code since dealing with tables has been a pain :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
fixedheadertable.com 上有一个非常简单的基于 jQuery 的解决方案。
There's a really simple jQuery-based solution at fixedheadertable.com.
找到了一个解决方案,它是一个 jquery 插件,可以格式化表格并自动检测列中的值,从而可以正确对它们进行排序。它还生成一个漂亮的 ui 界面,可以根据您的喜好设计样式:
http://www.datatables.net/
Found a solution, its a jquery plugin that formats tables and autodetects the values in the columns which can sort them correctly. It also produces a nice ui interface that can be styled to your liking:
http://www.datatables.net/