html – 在所有页面上打印页眉/页脚(打印模式)

<div id="header">header</div>
<div id="content">
    content spanning several pages...
</div>
<div id="footer">Footer - Fixed at the bottom of each page</div>

我想在打印模式下在每个页面上打印#header和#footer。我搜了很多,但没有什么似乎工作,甚至位置:固定不按预期工作。

我真的很感谢任何帮助。

谢谢!

解决方法

如果您愿意切换到表格(不一定是理想的),您可以使用< aad>和< tfoot>元素。他们将打印在每页的顶部和底部
<table>

  <thead>
     <!-- Will print at the top of every page -->
  </thead>

  <tbody>
     <!-- Page content -->
  </tbody>

  <tfoot>
     <!-- Will print at the bottom of every page -->
  </tfoot>

</table>

一个选择是使用display table-header-group和table-footer-group,但跨浏览器的支持并不是很大:

#header {
  display: table-header-group;
}

#main {
  display: table-row-group;
}

#footer {
  display: table-footer-group;
}

相关文章

vue阻止冒泡事件 阻止点击事件的执行 &lt;div @click=&a...
尝试过使用网友说的API接口获取 找到的都是失效了 暂时就使用...
后台我拿的数据是这样的格式: [ {id:1 , parentId: 0, name:...
JAVA下载文件防重复点击,防止多次下载请求,Cookie方式快速简...
Mip是什么意思以及作用有哪些