【发布时间】:2016-05-19 17:29:38
【问题描述】:
我需要打印 HTML 页面中的一个部分。我使用下面的 JS 方法来打印它。
printWindow.print();
我就是这样做的。
$("#toprint").on("click", function () {
var divContents = $("#tobebilled").html();
var printWindow = window.open('', '', 'height=400,width=800');
printWindow.document.write('<link rel="stylesheet" type="text/css" href="style/print.css"/>');
printWindow.document.write('<html><head><title>Print Bill</title>');
printWindow.document.write('</head><body >');
printWindow.document.write(divContents);
printWindow.document.write('</body></html>');
printWindow.document.close();
printWindow.print();
问题是我使用了 3 个 css 文件
Custom.min.css
bootstrap.min.css
components.min.css
在我的打印输出中,我似乎无法应用这些样式。打印出来的是原始的。如何应用 CSS?
【问题讨论】:
标签: javascript html twitter-bootstrap css