iframe.contentWindow.print()打印局部页面时,去掉页眉页脚
<style media="print">
@page {
size: auto; /* auto is the initial value */
margin: 0mm 10mm; /* this affects the margin in the printer settings */
}
</style>
页面做打印的时候,用了网上的方法不好使,后来才发现加错位置了,iframe嵌套的页面要把这段样式加到子页面(reportOverviewPrint.html)里面,也就是iframe页面里面,我一开始加在了父页面里面。
@page:设置页面容器的版式,方向,边空等。
margin(上 右 下 左) :打印时的边缘留白,上下为0时,才可以没有页眉和页脚;同时左右的边距是可以调节的,因为如果是0,左右留白太少,10mm比较合适。
相关代码如下:
<button type="button" class="btn btn-primary" id="btn-print" style="padding: 4px 30px;"