我需要打印多个页面和页脚需要打印在最后一页底部.我已经为这样的页脚添加了css
footer {
display: block;
width:100%;
position:absolute;
left:0;
bottom:0px;
}
Run Code Online (Sandbox Code Playgroud)
问题是页脚是打印第一页,但我需要在最后一页.
包含一个样式表,其中包含您自定义的页脚样式,以便使用media="print"
as进行打印
<link rel="stylesheet" href="yourpath/footerstyle.css" media="print"/>\n
Run Code Online (Sandbox Code Playgroud)\n\n或者
\n\n像在 html 中一样嵌入样式
\n\n<style>\n@media print {\n footer {\n display: block;\n width:100%; \n position:absolute;\n left:0;\n bottom:0; \n }\n}\n</style>\n
Run Code Online (Sandbox Code Playgroud)\n\n或者
\n\n<style type="text/css" media="print">\n footer {\n display: block;\n width:100%; \n position:absolute;\n left:0;\n bottom:0; \n }\n</style>\n
Run Code Online (Sandbox Code Playgroud)\n\n尝试将正文定位为相对位置,将页脚定位为绝对位置:
\n\n<style type="text/css" media="print">\n body {\n position: relative;\n }\n footer {\n display: block;\n width:100%; \n position:absolute;\n left:0;\n bottom:0; \n }\n</style>\n
Run Code Online (Sandbox Code Playgroud)\n\n或者你可以使用这样的东西:
\n\n@page:last {\n @bottom-center {\n content: "\xe2\x80\xa6";\n }\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n\n\n编辑
\n\n<style type="text/css" media="print">\n body {\n position: relative;\n margin: 0;\n }\n .page-section {\n\n /* Specify physical size of page, margins may vary by browser */\n\n height: 10 in; /* or give size as per proper calculation of the height of all your pages after which you want footer */\n position: relative;\n }\n footer {\n display: block;\n width:100%; \n position:absolute;\n left:0;\n bottom:0; \n }\n</style>\n
Run Code Online (Sandbox Code Playgroud)\n\n.page-section
根据您希望每页打印的 div添加到相关的 div / div 或直接添加到body
标签。