考虑下表:
<table>
<caption>The caption</caption>
<thead>...</thead>
<tbody>...</tbody>
<tfoot>...</tfoot>
</table>
表格在屏幕上显示时会正确呈现,但在打印时会破坏表格以换取新页面。当我删除标题元素或 display:none 时,表格会在打印时正确呈现。
有什么帮助吗?
考虑下表:
<table>
<caption>The caption</caption>
<thead>...</thead>
<tbody>...</tbody>
<tfoot>...</tfoot>
</table>
表格在屏幕上显示时会正确呈现,但在打印时会破坏表格以换取新页面。当我删除标题元素或 display:none 时,表格会在打印时正确呈现。
有什么帮助吗?
根据 W3C:
表格元素table、tr、td、th 和caption 应该有它们的标准含义和显示处理方式:table、table-row、table-cell 和table-caption。
据我了解,这意味着
caption { display: table-caption; }
编辑:我找到了更准确的风格:
TABLE { display: table }
TR { display: table-row }
THEAD { display: table-header-group }
TBODY { display: table-row-group }
TFOOT { display: table-footer-group }
COL { display: table-column }
COLGROUP { display: table-column-group }
TD, TH { display: table-cell }
CAPTION { display: table-caption }
请告诉我这是否适合您。
有关该主题的更多详细信息,请访问此页面