我在需要打印的网页中创建了表格。 在主页上,我有一个打印机友好按钮,可以打开一个新选项卡,该选项卡仅显示我需要打印的表格和内容。 当我转到新选项卡并尝试打印或获取打印预览时,它完全是空白的。 我可以在代码中做一些设置或其他事情来解决这个问题? 我也在使用angularjs。这发生在Chrome和IE中。任何帮助,不胜感激。*如果需要显示任何代码,请告知。 不确定是代码还是打印设置。
此代码获取要在打印预览中显示的内容 更新
@media print {
body *{
font-family: 'Open Sans', sans-serif;
font-size: 12px;
font-weight: 500;
color: #101010;
background: #f6f5fa;
visibility: hidden;
}
#section-to-print, #section-to-print *{
visibility: visible;
}
#section-to-print {
position:absolute;
left:0;
top:0;
}
#section-to-print2, #section-to-print2 *{
visibility: visible;
}
#section-to-print2 {
position:absolute;
left:0;
top:0;
}
}
请检查下面的代码,它在打印预览中显示内容。
JS小提琴
.HTML:
<a href="javascript:window.print()">Print this page</a>
<br>
<div id="section-to-print">
I crea ted tables in a web page that I need to print. On the main page I have a printerFriendly button that opens a new tab that shows just the table and content I need printed. When I go to the new tab and try to print or get a print preview, it is completely blank. There is some setting or something in the code I can do to fix this? I am also using angularjs. This happens in Chrome and IE. Any help is appreciated. *If any code needs to be shown, please let know. Not sure if it is the code or the print settings.
</div>
.CSS:
@media print {
body *{
font-family: 'Open Sans', sans-serif;
font-size: 12px;
font-weight: 500;
color: #101010;
background: #f6f5fa;
visibility: hidden;
}
#section-to-print, #section-to-print *{
visibility: visible;
}
#section-to-print {
position:absolute;
left:0;
top:0;
}
}