是否有任何限制使其无法在Firefox中的每个页面上打印?

问题描述 投票:3回答:3

我有一张桌子有<thead><tfoot><tbody>。它应该在理论上打印每页上的thead和tfoot,但由于某种原因,如果它包含某些元素,那么它就不会。

这有效:

<thead>
    <tr>
        <td colspan="3">This works</td>
    <tr>
    <tr>
        <th colspan="2">column 1</th>
    <th>
        column 2
        </th>
</tr>
</thead>

这似乎不起作用:

[编辑]

<table>
    <thead>
        <tr>
            <td colspan="3">
                <h2>Header</h2>
                    <address>
                        <strong>address 1</strong> <br />
                        address 2 <br />
                        address 3 <br />
                    </address>
                 <img src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b7/Wikipedia-logo.svg/600px-Wikipedia-logo.svg.png" alt="Logo" />
                 <h2>Another header</h2>
                 <hr />
            </td>
        </tr>
        <tr>
            <th colspan="2">column 1</th>
        <th>
            column 2
            </th>
    </tr>
    </thead>
    <tfoot>
        <tr>
            <td>This is the footer</td>
            <td>Column 2</td>
            <td>Column 3</td>
        </tr>
    </tfoot>
    <tbody>
        <?php for ($i = 0; $i < 100; $i ++): ?>
        <tr>
            <td>Col 1</td>
            <td>Col 2</td>
            <td>Col 3</td>
        </tr>
        <?php endfor; ?>
    </tbody>
</table>

[/编辑]

它打印:

[page 1]
    [header]
    [body]
    [footer]

[page 2,3,4,5]
    [body]
    [footer]

有没有理由不这样做?

html firefox printing
3个回答
6
投票

在你的打印CSS中添加:

thead{
  display:table-header-group;/*repeat table headers on each page*/
}
tbody{
  display:table-row-group;
}
tfoot{
  display:table-footer-group;/*repeat table footers on each page*/
}

根据您的需求进行调整

更新

在获取最新的HTML并使用它之后,我发现每页上重复的内容都有一个高度限制。

我改变THEAD包含:

<tr><td><div style="min-height:251px;">Hello World</div></td></tr>

如果我重复THEAD(已更改)和TFOOT(原样)......我只能使用高达251px的高度。试图进入任何更高的高度会导致THEAD部分不再重复。

我将保存关于这是一个功能还是一个错误的“辩论”...但我认为如果你有一个高于250px的重复标题,它可能会从一些收缩中受益。 ;-)


1
投票

如果对thead height的限制是个问题,那么使用css编码将每个标题标签放在页面顶部。

有关更多信息,请参阅以下链接:How to use HTML to print header and footer on every printed page of a document?


0
投票

加上@scunliffe的回答。我已将此添加到我的CSS中,因此它尽可能地将我的thead压缩到这个大小,并在IE11和Chrome 62中的所有页面中重复它

  thead {
        display: table-header-group;
       max-height:250px;
    }
© www.soinside.com 2019 - 2024. All rights reserved.