2016-03-29 3 views
-3

私は今この問題をしばらく解決しようとしています。この問題はChromeにのみ関連しています。私がテーブルセルで作業しているウェブサイト上のページを印刷すると、行全体が表示されます。したがって、印刷ページに5行の表を表示するのではなく、各セルを1幅の行として表示します。私はtdとテーブルの幅を制御するために使用しようとした印刷ページCSSを持っていますが、まだ各セルを新しい行にドロップします。 FireFoxを使用して完全に印刷します。どんな助けでも大歓迎です。クロームテーブルの問題のページを印刷する

ありがとうございました。

+0

[ask]をお読みください。 – CBroe

答えて

0
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; 


    }