我想在打印模式下将页眉和页脚放在每个页面中.我做了很多研究.
我找到了两个解决方案.但它们不是跨浏览器(我希望它能在IE,Firefox和Chrome中运行)
第一个解决方案:我在内容表的顶部和底部设置边距.然后我用固定位置写这个空间的页眉和页脚.它在Firefox中运行良好.但在IE和Chrome中并没有设定利润率.同样在Chrome中,它不会为每个页面编写页眉和页脚.
这是我的代码:
pagination.PHP
- <!DOCTYPE HTL>
- <html>
- <head>
- <Meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9">
- <Meta name="robots" content="noindex,nofollow">
- <Meta name="googlebot" content="noindex">
- <Meta http-equiv="cache-control" content="no-cache">
- <title>Brove.NET ISO Yazılımı</title>
- <link rel="stylesheet" type="text/css" href="css/pagination.css" />
- </head>
- <body>
- <table class="header" cellpadding="0" cellspacing="0">
- <tr>
- <td>header
- </td>
- </tr>
- </table>
- <table class="content" cellpadding="0" cellspacing="0">
- <tr>
- <td valign="top">
- content
- </td>
- </tr>
- </table>
- <table class="footer" cellpadding="0" cellspacing="0">
- <tr>
- <td>footer
- </td>
- </tr>
- </table>
- </body>
- </html>
pagination.css
- @media screen{
- .header{
- width:768px;
- height:100px;
- border:2px solid #000;
- }
- .content{
- width:768px;
- margin-top:10px;
- margin-bottom:10px;
- height:1000px;
- }
- .footer{
- width:768px;
- height:100px;
- border:2px solid #000;
- }
- }
- @media print {
- .header{
- position:fixed;
- top:0;
- left:0;
- width:768px;
- height:100px;
- border:2px solid #000;
- }
- .content{
- width:768px;
- margin-top:120px;
- margin-bottom:120px;
- height:1000px;
- }
- .footer{
- position:fixed;
- left:0;
- bottom:0;
- width:768px;
- height:100px;
- border:2px solid #000;
- }
- @page{
- margin-bottom:150px;
- }
- }
这是第二个解决方案:
在此解决方案中,我使用table-header-group和table-footer-group属性.它适用于Firefox和IE.但Chrome不再理解.在打印模式下,它不会在每个页面中重复页眉和页脚.
这是另一个代码:Is there a way to get a web page header/footer printed on every page?
- <style type="text/css">
- thead { display: table-header-group; }
- tfoot { display: table-footer-group; }
- </style>
- <body>
- <table>
- <thead><tr><td>Your header goes here</td></tr></thead>
- <tfoot><tr><td>Your footer goes here</td></tr></tfoot>
- <tbody>
- <tr><td>
- Page body in here -- as long as it needs to be
- </td></tr>
- </tbody>
- </table>
- </body>
是否有任何黑客可以解决这个浏览器问题,或者您对我有什么建议吗?