我有一份特定的文件。背景第一页和最后一页与文档的其他页面不同。
根据这里回答的问题: Flying Saucer hide header and footer on first page
我使用技巧@page :first
定义的第一页:
@page{
background-image: url('... my regular background ...');
}
@page :first {
background-image: url('... first page background ... ');
}
如何更改最后一页的背景?
答案 0 :(得分:1)
如果您事先知道最后一页上会显示什么,则可以使用CSS3 named pages。
这是一个简单的例子:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
.newpage{page-break-before:always}
@page {@bottom-center {content: element(footer)}}
#footer {position: running(footer);}
@page last {@bottom-center {content: element(lastfooter)}}
#lastfooter{position: running(lastfooter);}
#lastpage {page:last}
}
</style>
</head>
<body>
<div id="footer">Footer page 1 and 2</div>
<div id="lastfooter">Footer for last page</div>
<div>Page 1 content</div>
<div class="newpage">Page 2 content</div>
<div id="lastpage">Page 3 content</div>
</body>
</html>