我需要默认的引导css留原样时,打印一个固定的标题的表格,但需要覆盖一些与溢出相关的样式,因为表格是垂直滚动的。
基本上,我想让targetStyles:'*‘与我的bootstrap css模板中的内容相匹配,但需要覆盖tbody {overflow:auto}和另一个自定义样式.table-responsive {overflow-x:auto}。如何在保留所有引导css的同时更改打印作业的这两种样式?
我已经尝试使用targetStyles:和style:,并列出了这两种样式。对于这种情况,https://printjs.crabbly.com/#documentation很有帮助,但还不够直观
/* my table is contained in a div with id of #howDoingTable */
printJS({
printable: 'howDoingTable',
type: 'html',
targetStyles: ['*'],
style: '#howDoingTable tbody {overflow:none;} #howDoingTable.table-responsive {overflow-x:none;}'
});
/*It's ignoring the style with the two overrides I want to implement via style:*/发布于 2019-07-24 04:50:14
除非在当前提供的printJS中不能做到这一点,否则我发现解决方法是在调用printJS之前更改需要更改的样式,然后在调用jQuery之后立即重新启用它们:
//change overflow css to visible to remove scrolling in the ui
$("#howDoingTable.table-responsive").css("overflow-x","visible");
$("#howDoingTable tbody").css("overflow","visible");
printJS({
printable: 'howDoingTable',
type: 'html',
targetStyles: ['*']
});
//change the overflow css properties back to scrolling
$("#howDoingTable.table-responsive").css("overflow-x","auto");
$("#howDoingTable tbody").css("overflow","auto");https://stackoverflow.com/questions/57155265
复制相似问题