为什么div.tablesorter-sticky-wrapper left设置总是为零?

时间:2014-11-07 21:10:47

标签: jquery tablesorter

我在这里使用tablesorter版本2.18.2和stickyHeaders小部件:

http://mottie.github.io/tablesorter/docs/example-widget-sticky-header.html

当屏幕上出现stickyHeader时,它位于绝对位置,左侧始终为零。我的表不在零位置,因此stickyHeader出现在错误的位置。

左边的设置不应该是桌子的左边位置吗?这是一个错误吗?

我尝试了cssStickyHeaders小部件,它正确定位了stickyHeader,但没有提供z-index选项。我需要将z-index设置为4,以便标题出现在表格中的控件之上。

1 个答案:

答案 0 :(得分:0)

小部件旨在添加表左位置,左边距和左边距。用于对齐克隆标头的填充。如果您需要修改z-index,则stickyHeaders_zIndex选项可用。

小部件应该按原样运行。我创建了this demo,表格设置为向右浮动,并且它正确排列。

我相信您遇到的问题是使用stickyHeaders_attachTo选项将克隆附加到表包装器(demo

$(function () {
    $('table').tablesorter({
        theme: 'blue',
        widgets: ['zebra', 'stickyHeaders'],
        widgetOptions: {
            stickyHeaders_attachTo: $('#wrapper'),
            stickyHeaders_yScroll: $(window),
            stickyHeaders_zIndex: 2
        }
    });
});

解决方案是将position: relative添加到包装器(demo