簡體   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