【问题标题】:table-header-group and table-footer-group in a DivDiv 中的 table-header-group 和 table-footer-group
【发布时间】:2017-05-20 23:54:51
【问题描述】:

有没有办法在 div 中使用 table-header-group 和 table-footer-group 而不是在 thead 或 tfoot 中?

【问题讨论】:

    标签: html html-table


    【解决方案1】:

    根据www.w3.org,当父级(包含 div 的元素)显示为表格或内联表格时,允许使用display: table-header-group。所以应该允许这样的事情

    <table>
      <div style="display: table-header-group;">header group</div>
    </table>
    

    如果父级不是表,则应根据www.w3.org 页面上的第 4 点将其插入。

    最大的问题是,是否所有(主要)浏览器都支持这一点。尤其是 IE(6) 以不支持大多数类型的显示类型而闻名。

    【讨论】:

      【解决方案2】:

      根据 W3C,您不能将元素用作 &lt;table&gt; 内的直接子节点。 http://w3schools.com/html5/tag_table.asp。本文指出&lt;table&gt; 可能包含:

      • tr
      • td
      • 标题
      • col
      • colgroup
      • 身体

      如果你想避免使用表格,你可以做的是:

      <div style="display:table;">
        <div style="display:table-header-group;">header group</div>
      </div>
      

      然而,这种解决方案只能在 HTML5 中使用。

      【讨论】:

        猜你喜欢
        • 2014-06-14
        • 2012-02-17
        • 1970-01-01
        • 2015-12-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-05-29
        • 2020-09-07
        相关资源
        最近更新 更多