有没有办法在div中使用table-header-group和table-footer-group而不是在thead或tfoot中?
答案 0 :(得分:6)
根据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)因不支持大多数类型的显示类型而闻名。
答案 1 :(得分:3)
根据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。