css-paged-media – 页面和页脚在每个页面以打印模式与css

我有一个Web应用程序,它有一个可能超过一页的报告,我想在每个页面打印页眉和页脚.
我找到并尝试这样:
Repeating a report header in each page
但它没有为我工作.我尝试歌剧,IE9,Firefox,谷歌浏览器,但…没有.页边距工作正常,但内容是我想要的,它不起作用.

解决方法

你可以设置一个位置:固定;页眉和页脚,以便在每个页面上重复

例如

<header class="onlyprint"><!--Content Goes Here--></header>
<footer class="onlyprint"><!--Content Goes Here--></footer>

@media screen {
    header.onlyprint,footer.onlyprint{
        display: none; /* Hide from screen */
    }
}

@media print {
    header.onlyprint {
        position: fixed; /* display only on print page (each) */
        top: 0; /* Because it's header */
    }
    footer.onlyprint {
        position: fixed;
        bottom: 0; /* Because it's footer */
    }
}

相关文章

Css3如何实现鼠标移上变长特效?(图文+视频)
css3怎么实现鼠标悬停图片时缓慢变大效果?(图文+视频)
jquery如何实现点击网页回到顶部效果?(图文+视频)
css3边框阴影效果怎么做?(图文+视频)
css怎么实现圆角边框和圆形效果?(图文+视频教程)
Css3如何实现旋转移动动画特效