微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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;
}

原文地址:https://www.jb51.cc/html/233415.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐