使用jQuery的可滚动表

时间:2009-02-24 19:01:40

标签: jquery css jquery-ui jquery-plugins

有没有好的和轻量级的jQuery插件可以制作Scrollable Tables。

我在http://www.webtoolkit.info/scrollable-html-table-plugin-for-jquery.html获得了一个,但这不适用于非IE浏览器和非FF浏览器。

谢谢!

2 个答案:

答案 0 :(得分:6)

如果您正在寻找轻量代码,请完全跳过jQuery并使用纯HTML / CSS:

<table>
    <thead>
        <tr><th>Header Item 1</th><th>Header Item 2</th></tr>
    </thead>
    <tfoot>
        <tr><th>Footer Item 1</th><th>Footer Item 2</th></tr>
    </tfoot>
    <tbody style="overflow-y: scroll; overflow-x: hidden; height: 100px;">
        <tr><td>Item 1-1</td><td>Item 2-1</td></tr>
        ...
        <tr><td>Item 1-N</td><td>Item 2-N</td></tr>
    </tbody>
</table>

关键是在tbody中设置溢出CSS,以便使该部分可滚动(但不是整个表)。您还需要设置高度,以便定义可滚动部分的高度。

答案 1 :(得分:3)

这是一个运作良好的: http://www.farinspace.com/jquery-scrollable-table-plugin/

由于上面提到过,这里是一个纯HTML / CSS跨浏览器解决方案: http://www.imaputz.com/cssStuff/bigFourVersion.html