【发布时间】:2016-02-28 00:41:26
【问题描述】:
我正在尝试使用 printThis jQuery 插件在我的网页上打印一些“选择”的内容。当我按print_btn 时,打印中没有图像或<hr> 显示。为什么?
HTML
<button id="print_btn"></button>
<div class="elementBricka display" style="page-break-after:always">
<div class="lkbLoggo"></div>
<hr>
....
CSS
#elementBrickor{
align-items: center;
}
.elementBricka{
width: 9.614cm;
height: 14.404cm;
border: 1px solid;
background-color: white;
float: none;
margin-left: auto;
margin-right: auto;
}
.lkbLoggo{
width: 9.182cm;
height: 2.721cm;
margin-top: 0.199cm;
background-image: url("/img/lkb_logga2.png");
background-repeat: no-repeat;
background-position: center;
}
JS
$(document).ready(function () {
$('#print_btn').click(function () {
$('.display').printThis({
debug: true,
importCSS: true,
importStyle: true,
loadCSS: "/Data.css",
pageTitle: false,
});
});
});
更新
我会回答我自己的问题。
这与“PrintThis”无关。
这是一个浏览器“问题”。
但是通过在我加载 img 的 Css 文件中添加:!important 很容易解决。
【问题讨论】:
-
应该打印图像 - 你有示例页面吗?我是 printThis 的作者,所以我想追查任何错误。
-
这是一个演示图像工作的演示:jsbin.com/lelefihowe/edit?output
-
@Jason 我所要做的就是在我加载 img 的 CSS 中添加“!important”。所以,这不是“PrintThis”问题。谢谢。
标签: javascript jquery html css printthis