带有 CSS/HTML 的页码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6109893/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Page numbers with CSS/HTML
提问by balupton
An interesting use case has popped up for us, we are requiring that when we print a website the printed copy will have a page header and footer, and inside the footer the page number.
一个有趣的用例出现在我们面前,我们要求当我们打印网站时,打印的副本将有页眉和页脚,页脚内有页码。
Anyone got any idea how to achieve this?
任何人都知道如何实现这一目标?
Note: Browser version can be the latest of anything, clients are other web developers.
注意:浏览器版本可以是最新的,客户端是其他 Web 开发人员。
回答by alex
Depending on your required browser support.
取决于您所需的浏览器支持。
@page {
@bottom-right {
content: counter(page) " of " counter(pages);
}
}
Further reading:
进一步阅读:
回答by Page Notes
There's a test page at http://www.princexml.com/howcome/2007/xtech/papers/output/0082-32/index.xhtmlthat includes the @page content code in its css file. I couldn't get it to work in current versions of IE, Chrome, or Firefox.
http://www.princexml.com/howcome/2007/xtech/papers/output/0082-32/index.xhtml上有一个测试页面,它的 css 文件中包含 @page 内容代码。我无法在当前版本的 IE、Chrome 或 Firefox 中使用它。