html - 固定每个打印页面上的页眉,并避免页脚内部出现分页符
问题描述
我的页面中有三个Div,类为invoiceHeader、invoiceBody 和invoiceFooter。我想在每个打印页面上重复第一个 div (.invoiceHeader),并且我想避免在打印时在第三个 Div (.invoiceFooter) 内部分页,页面上将没有页脚。我怎样才能做到这一点?
解决方案
以下代码可以帮助您作为粘性页眉和页脚进行打印
@media print {
.centerDiv{
width: 80%;
margin: 0 auto; /* Center the DIV horizontally */
}
.fixed-header, .fixed-footer{
width: 100%;
position: fixed;
}
.fixed-header{
top: 0;
}
.fixed-footer{
bottom: 0;
}
}
推荐阅读
- android - 使用其 USB id 在特定设备上运行 CTS
- android -
- sql - 具有可变参数 varchar 输入和可变参数整数输出的 SQL 函数
- c# - 如何使用 ASP WebForms 将日志文件流式传输到网页
- java - 当我们只有元素的标题时,如何获取某个列表元素的属性?
- css - 在调整大小时将 svg “粘贴”到元素的顶部
- php - 在 RHEL 7 中找不到 php-fpm PDO 驱动程序 mysql
- javascript - JavaScript 将许多函数括起来
- java - Java 嵌套的 foreach 循环
- python - 将许多列表参数传递给 Python 中的查询