HTML 中的表格可以有“页脚”:
<TABLE>
<THEAD><TR><TD>Your header goes here</TD></TR></THEAD>
<TFOOT><TR><TD>Your footer goes here</TD></TR></TFOOT>
<TBODY>
<TR><TD>
Page body in here -- as long as it needs to be
</TD></TR>
</TBODY>
</TABLE>
通常,旧版 Internet Explorer 只会在整个表格的底部显示 TFOOT
。但是有一种样式可以应用于 TFOOT
(和 THEAD
)以使其成为 print at the bottom of each page spanned by the table. From MSDN :
table-footer-group
Object is rendered as tFoot. Table footer is always displayed
after all other rows and row groups, and before any bottom captions.
The footer is displayed on each page spanned by a table.
将 table-footer-group
作为样式添加到 TFOOT
会导致它(在 Internet Explorer 中)打印在表格所跨越的每个页面的底部:
<STYLE type="text/css">
tfoot { display: table-footer-group; }
</STYLE>
但是如果 IE9(候选发布)被置于标准模式:
<!DOCTYPE html>
然后 TFOOT
不再呈现在跨表的每个页面的底部,而是仅呈现在整个表的末尾。
我检查了the HTML spec查看正确的行为是什么,它是未定义的!:
table-footer-group (In HTML: TFOOT)
Like 'table-row-group', but for visual formatting, the row group is always displayed after all other rows and row groups and before any bottom captions. Print user agents may repeat footer rows on each page spanned by a table. If a table contains multiple elements with 'display: table-footer-group', only the first is rendered as a footer; the others are treated as if they had 'display: table-row-group'.
注意:为效果添加了强调。
在 IE9 标准模式中,有没有一种方法可以让我选择在表格跨越的每个页面的底部打印一个 TFOOT
?
更新一
有趣的是,table-footer-group
是 TFOOT
元素的典型默认值,但在以前版本的 IE 中,您可以选择您想要的行为:
- 整个表格的底部
- 整个表格的底部和每个中间页
通过选择包含样式。
更新二
现在我强制 Internet Explorer 保持 IE8 标准模式:
<!DOCTYPE html>
<HTML>
<HEAD>
<META http-equiv="X-UA-Compatible" content="IE=8" />
<!--IE8 Standards mode, so that we get the THEAD at the top, and the TFOOT at the bottom, of every page-->
另见
最佳答案
在 HTML 中,行为未定义。浏览器可以:
- 显示在整个表格之后
- 显示在每个页面的底部。
我遇到的行为是在 Internet Explorer 9 Release Candidate 中。
在 Internet Explorer 9 的最终版本(版本 9.0.8112.1642 RTM)中,TFOOT
始终出现在每个打印页面的底部。
在早期版本的 IE 中,您可以选择:
TFOOT
出现在每个页面的底部TFOOT
出现在表格后面
通过手动指定 TFOOT
css 样式:
tfoot { display: table-footer-group; }
即使 tfoot
已经具有 table-footer-group
的显示样式,特别是包含它会告诉 IE 您想要打印 TFOOT在每一页的底部。 (而不是在 table 之后)。
不指定它(默认行为)将使 IE 在整个表格之后打印TFOOT
。
如果您使用的是 IE9,并且希望在整个表格打印后只出现一个 TFOOT
,则必须将 Internet Explorer 设置为 IE8 标准模式:
<!DOCTYPE html>
<HTML>
<HEAD>
<META http-equiv="X-UA-Compatible" content="IE=8" />
<!--IE8 Standards mode, so that we get the TFOOT after the entire table has printed, not at the bottom of each printed page-->
...
关于HTML:IE9 标准模式在每个页面上打印 TFOOT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5252297/