【问题标题】:Print page in chrome table issueschrome table 问题中的打印页面
【发布时间】:2016-07-16 22:00:48
【问题描述】:

我已经尝试解决这个问题一段时间了。此问题仅与 Chrome 有关。当我在网站上打印页面时,我正在处理表格单元格跨越整行。因此,与其在打印页面中有一个包含 5 行的表格,它会将每个单元格显示为 1 个全宽行。我有一个打印页面 css,我试图用它来控制 td 和表格的宽度,但是它仍然将每个单元格放到一个新行中。使用 FireFox 完美打印。任何帮助将不胜感激。

谢谢。

【问题讨论】:

标签: html google-chrome printing


【解决方案1】:
Try this way:
where var data= $("#divtoprint").html();
  function ShowPrintWindowPopup(data) {
        var mywindow = window.open();
        mywindow.document.write('<html><head><title></title>');
        mywindow.document.write('<style>');
        mywindow.document.write('table, th, td { border-collapse: collapse;border: 1px solid black;width: 100%;text-align: left;border-spacing: 0;}');
        mywindow.document.write('a {color: #428bca;text-decoration: none;} ,table > tbody > tr {height:auto!important},table > thead > tr > th, table > tbody > tr > th, table > tfoot > tr > th, table > thead > tr > td, table > tbody > tr > td, table > tfoot > tr > td{vertical-align:top;padding:2px;font-size:8px;}');
        mywindow.document.write('table {border-collapse:collapse; table-layout:fixed;} , table td {border:solid 1px #fab; word-wrap:break-word; -ms-word-break: break-all; word-break: break-all; word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;-ms-hyphens: auto;hyphens: auto;}')
        mywindow.document.write('</style>');
        mywindow.document.write('</head><body style="direction:ltr;font-size:10px;">');
        mywindow.document.write('<div style="text-align:center;font-size:16px;font-weight:bold;">title</div><br />');
        mywindow.document.write('<br/><br/>');
        mywindow.document.write(data);
        mywindow.document.write('</body></html>');
        mywindow.document.close();
        mywindow.print();
        return true;


    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-04-05
    • 1970-01-01
    • 2011-01-15
    • 1970-01-01
    • 2019-12-04
    • 2012-07-06
    • 1970-01-01
    相关资源
    最近更新 更多