繁体   English   中英

使用printJS调整Div宽度

[英]Adjusting Div Width with printJS

我正在尝试使用PrintJS库。 它允许您定位特定的id并打印该id中包含的html。 我面临的问题是当我改变屏幕的大小时,它也会改变div的打印尺寸。 它们为您提供了传入css的选项,但并未应用所有更改。

这是我的测试用法:

printJS({printable: 'oogles', type: 'html', style: '.modal-header { color: red; width: 100px; } .modal-body { width:100% }'})

某些css更改已成功应用于样式部分,如color: red但更改宽度似乎不起作用。 我试过width: 100%; 或任意设置宽度的特定width: 100px;

HTML:

    <div id='oogles'>
      <div class='modal-header'>wooooooo we are printing some things!</div>
      <div class='modal-body'>well we are trying at least</div>
    </div>

有没有人有使用PrintJS调整元素宽度进行打印的经验?

谢谢

尝试将样式表传递给库。 如果HTML没有任何内联样式标记,则如果禁用lib的样式处理,则更好。

例如:

printJS({
  printable: 'oogles', 
  type: 'html', 
  style: '.modal-header { color: red; width: 100px; } .modal-body { width:100% }'
  css: [
         'my_stylesheet_1',
         'my_stylesheet_2.css'
  ],
  scanStyles: false
})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM