简体   繁体   English

如何获得固定的标题以在滚动html表中工作(标题有多行时)

[英]How to get fixed header to work in scrolling html table (when header has multiple rows)

I managed to get fixed header in scrolling table working with this plugin (and also tried numerous other ones)... with a catch. 我设法在使用此插件的滚动表中获得了固定的标头(并且还尝试了许多其他插件 )。

None of them work if our tables have multiple rows in the header. 如果我们的表的头中有多行,它们都不起作用。

eg 例如

Think of a table like this: 考虑这样的表:

<table>
  <thead>
  <tr>
    title of the table
  </tr>
  <tr>
    <th>col 1</th>
    <th>col 2</th>
    ...
  </tr>
  </thead>
  ...

When I take out either of the two rows in <thead> , the plugin I linked and many other solutions work. 当我取出<thead>中的两行之一时,我链接的插件和许多其他解决方案都可以工作。 However, for some of the tables they HAVE to have both the column headers AND the table name, so removing one of the two simply isn't an option. 但是,对于某些表,它们既要具有列标题又要具有表名,因此根本不能删除两个表之一。

Is there a way to merge the two rows in the header to one in html? 有没有一种方法可以将标头中的两行合并为html中的一行? Or is there a way to get the plugins to work nicely with multiple rows in the header? 还是有一种方法可以使插件与标头中的多行完美配合? I have been googling around a ton on the scrolling tables with fixed headers, but I've yet to find any that works with multiple rows in the header. 我一直在使用固定标题在滚动表上进行大量搜索,但是我还没有找到可以在标题中使用多行的内容。

Maybe try something like this, the Table Title should take up the whole width if done this way 也许尝试这样,表格标题应该占用整个宽度

 <thead>
  <tr>
    <div id="table_head_div">

        <div id="table_title" style="height:50%; width:100%; margin:0; padding:0;">Table Title</div>

        <div id="column_titles" style="height:50%; width:100%; margin:0; padding:0;">
            <div class="column_title">column 1</div>
            <div class="column_title">column 2</div>
            <div class="column_title">column 3</div>
        </div>

    </div>
  </tr>
  </thead>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM