如何在Chrome中的每个打印页面上打印部分网页(标题)

San*_*non 7 html javascript css jquery

我正在处理发票打印脚本.发票号码必须打印在所有打印页面的顶部.我用php来实现这个目的.但这里我只是复制html版本.这个脚本在FF和IE中工作正常,但不能在chrome中工作.在FF中,我可以看到发票编号出现在打印视图中所有页面的标题部分中.我删除了所有不必要的代码以获得清晰的代码.我需要在每个打印页面中看到"发票编号:A23000BN".有没有办法在Chrome浏览器中实现相同的目标?我的html脚本如下:

<html>
<head>
<style>
#header {
    text-align: right;
    height: 20px;
    position: fixed;
    margin: 0px;
    bottom: 0px;
}
</style>
</head>
<body>
<table width="100%">
   <tr>
      <td height="1200"></td>
   </tr>
</table>
<div class="header"> Invoice Number : A23000BN </div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

use*_*463 0

像这样的东西? https://jsfiddle.net/1xnnnp4b/2/

按 Ctrl+P 即可获取打印预览中的内容(在屏幕版本中将不可见)

.header {
  display: none;
}

@media print {
  .header {
    display: block;
    position: fixed;
  }
}
Run Code Online (Sandbox Code Playgroud)
<div class="header">
  Invoice Number : A23000BN
</div>
<table width="100%">
  <tr>
    <td height="1500">sameple content
    </td>
  </tr>
</table>
Run Code Online (Sandbox Code Playgroud)

编辑:我认为这应该可以。您需要将更改复制到您的页面,然后尝试。它不会在 jsfiddle 中正常工作,因为父区域已经oveflow