【发布时间】:2017-05-20 23:54:51
【问题描述】:
有没有办法在 div 中使用 table-header-group 和 table-footer-group 而不是在 thead 或 tfoot 中?
【问题讨论】:
标签: html html-table
有没有办法在 div 中使用 table-header-group 和 table-footer-group 而不是在 thead 或 tfoot 中?
【问题讨论】:
标签: html html-table
根据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) 以不支持大多数类型的显示类型而闻名。
【讨论】:
根据 W3C,您不能将元素用作 <table> 内的直接子节点。 http://w3schools.com/html5/tag_table.asp。本文指出<table> 可能包含:
如果你想避免使用表格,你可以做的是:
<div style="display:table;">
<div style="display:table-header-group;">header group</div>
</div>
然而,这种解决方案只能在 HTML5 中使用。
【讨论】: