JS 添加css樣式

JS 添加css樣式

function addStyle(newStyle) {
  var styleElement = document.getElementById('styles_js');

  if (!styleElement) {
    styleElement = document.createElement('style');
    styleElement.type = 'text/css';
    styleElement.id = 'styles_js';
    styleElement.media = 'print';
    document.getElementsByTagName('head')[0].appendChild(styleElement);
  }

  styleElement.appendChild(document.createTextNode(newStyle));
}

var css = `
@page { size: 21.7cm 9.2cm; margin: 0;}

*{
white-space: nowrap;font-size: 12px;
}
.OutboundOrderPrint .Thetitle{
page-break-after: always;
}
.OutboundOrderPrint .Thetitle .Title{
font-size: 18px;
}
.OutboundOrderPrint .Thetitle .TableBox .Note{
white-space: normal;
}`
;
addStyle(css);
相關文章
相關標籤/搜索