【问题标题】:HTML table maintain column width on printHTML表格在打印时保持列宽
【发布时间】:2019-05-20 19:00:45
【问题描述】:

我有一张这样的桌子:

<table>
<thead>
    <th>Name</th>
    <th>Age</th>
    <th>Class</th>
    <th>Roll No</th>
    <th>Mobile</th>
    <th>Address</th>
</thead>
<tbody>
  <tr>
     <td>Ankush</td>
     <td>15</td>
     <td>10th</td>
     <td>105</td>
     <td style="width:10%">1234567890</td>
     <td style="width:20%">xyzdegdgrebrhbrgh</td>
  </tr>
</tbody>
</table>

表格在打​​印时丢失了自定义列宽。它在正常页面上工作正常,但列宽样式在打印时丢失。

【问题讨论】:

  • 您是否尝试将表格样式放入@media print css 中?
  • 尝试在您的打印 css 中添加固定的表格布局和断字

标签: html css printing html-table


【解决方案1】:

打印网页时,边距由浏览器设置设置。如果您的浏览器设置没问题,那么您应该使用针对“打印”的媒体查询。如果您想按照浏览器中显示的方式打印,则需要以绝对单位(如英寸)为单位设置主页高度和宽度。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-02-25
    • 2010-10-08
    • 2019-05-02
    • 2021-11-24
    • 1970-01-01
    • 1970-01-01
    • 2020-02-11
    • 2012-11-10
    相关资源
    最近更新 更多