最后一页页脚

问题描述 投票:0回答:2

我创建了一个 html 页面,提供打印他的内容(window.print)。我想使用以下 CSS 添加打印版本的页脚。

display: table-footer-group;

但我想在最后一页有一个页脚。上面的 CSS 为每个页面生成页脚。我该如何解决?谢谢。

html css printing
2个回答
0
投票

你可以尝试这样的事情:

@page:last {
    /* footer css here */
}

补充阅读。


0
投票

现在可以使用CSS为分页媒体模块生成内容使用运行元素

@page {
    @bottom-center {
        content: element(footer);
    }
}

.last-page-footer {
    position: running(footer);
}
<p>I'm the content. Extend me until I fit on several pages.</p>

<div class="last-page-footer">
    I'm the footer
</div>

截至 2024 年,浏览器不再正确支持这些属性。在它们受到支持之前,您可以使用 Paged.js 作为 polyfill:

Paged.js 是一些 CSS 属性的填充,用于从浏览器打印 HTML。 Paged.js 旨在实现的 W3C CSS 模块如下:

要将 Paged.js 用作 polyfill,请将下面的行复制到文档的

head

<script src="https://unpkg.com/pagedjs/dist/paged.polyfill.js"></script>
© www.soinside.com 2019 - 2024. All rights reserved.