Tbody滚动条问题

发布于 2024-11-18 21:55:56 字数 2306 浏览 3 评论 0原文

我想修改以下代码,以便 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"">&nbsp;</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:

enter image description here

Hopefully its a small edit in my code since dealing with tables has been a pain :(

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

骑趴 2024-11-25 21:55:56

fixedheadertable.com 上有一个非常简单的基于 jQuery 的解决方案。

There's a really simple jQuery-based solution at fixedheadertable.com.

拥有 2024-11-25 21:55:56

找到了一个解决方案,它是一个 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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文