这是我尝试过的 HTML 代码,您可以定义自定义页眉和页脚文本,并将显示在所有页面上(如果此 HTML 页面有多个页面),我也将其隐藏在浏览器中,但在打印时可见。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
@media screen {
.noPrint {
}
.noScreen {
display: none;
}
}
@media print {
.noPrint {
display: none;
}
.noScreen {
}
}
#header {
position: fixed;
width: 100%;
top: 0;
left: 0;
right: 0;
}
#footer {
position: fixed;
width: 100%;
bottom: 0;
left: 0;
right: 0;
}
body {
font: 12pt Georgia, "Times New Roman", Times, serif;
line-height: 1.3;
padding-top: 50px;
}
</style>
</head>
<body>
<div id="header" class="noScreen">
<h2>Header Content</h2>
</div>
<div id="footer" class="noScreen">
<h2>Footer Content</h2>
</div>
<!--Multiple page of contents-->
</body>
</html>
你去...希望这有帮助...
快乐的编码...