【问题标题】:How to adjust table or content in CSS when printing?打印时如何在 CSS 中调整表格或内容?
【发布时间】:2017-01-12 02:45:40
【问题描述】:

所以我有这个巨大的数据表,当我用legal 尺寸的纸张打印它时,我想把它们都装进去。现在我只有纸张的大小,但内容不适合它

这是我的CSS 代码:

@page {
  size:  legal;
}
@page :left {
  margin: 0.5cm;
}

@page :right {
  margin: 0.5cm;
}

这是我的table

<div class="table-responsive">
<table border="1" style="table-layout: fixed;" align="center">
  <caption class="center">PERSONAL</caption>
  <tr>
    <th align="left">NAME: </th>
    <td colspan="3"><input type="text" name="full_name" size="37" value="<?php echo $full_name; ?>" disabled></td>
    <th colspan="1" align="left">MOBILE: </th>
    <td><input type="text" name="phone_number" size="11" value="<?php echo $phone_number; ?>" disabled></td>
    <th align="left">RANK: </th>
    <td><input type="text" name="crew_rank" size="10" value="<?php echo $crew_rank; ?>" disabled></td>
  </tr>
  <tr>
    <th align="left">DATE OF BIRTH: </th>
    <td><input type="text" name="date_of_birth" size="17" value="<?php echo $date_of_birth; ?>" disabled></td>
    <th align="left">AGE: </th>
    <td><input type="text" name="age" size="5" value="<?php echo $age; ?>" disabled></td>
    <th align="left">TELEPHONE NUMBER: </th>
    <td><input type="text" name="telephone_number" size="11" value="<?php echo $telephone_number; ?>" disabled></td>
    <th align="left">VESSEL: </th>
    <td><input type="text" name="vessel" size="10" value="<?php echo $vessel; ?>" disabled></td>
  </tr>
  <tr>
    <th align="left">PLACE OF BIRTH: </th>
    <td colspan="3"><input type="text" name="place_of_birth" size="37" value="<?php echo $place_of_birth; ?>" disabled></td>
    <th colspan="1" align="left">RELIGION: </th>
    <td><input type="text" name="religion" size="11" value="<?php echo $religion; ?>" disabled></td>
    <th align="left">JOINING DATE: </th>
    <td><input type="text" name="joining_date" size="10" value="<?php echo $joining_date; ?>" disabled></td>
  </tr>
  <tr>
    <th align="left">CITIZENSHIP/CIVIL STATUS</th>
    <td><input type="text" name="citizenship" size="17" value="<?php echo $citizenship; ?>" disabled></td>
    <td colspan="2"><input type="text" name="civil_status" size="16" value="<?php echo $civil_status; ?>" disabled></td>
    <th colspan="1" align="left">SSS No.</th>
    <td colspan="1"><input type="text" name="sss_number" size="11" value="<?php echo $sss_number; ?>" disabled></td>
    <th align="left">JOINING PORT: </th>
    <td colspan="2"><input type="text" name="joining_port" size="10" value="<?php echo $joining_port; ?>" disabled></td>
  </tr>
  <tr>
    <th align="left">SHOES/BOILER SUIT SIZE</th>
    <td><input type="text" name="shoe_size" size="17" value="<?php echo $shoe_size; ?>" disabled></td>
    <td><input type="text" name="boiler_size" size="5" value="<?php echo $boiler_size; ?>" disabled></td>
    <th align="left">HT/WT</th>
    <td><input type="text" name="ht" size="19" value="<?php echo $ht; ?>" disabled></td>
    <td><input type="text" name="wt" size="11" value="<?php echo $wt; ?>" disabled></td>
    <th>LAST VESSEL: </th>
    <td><input type="text" name="last_vessel" size="10" value="<?php echo $last_vessel; ?>" disabled></td>
  </tr>
  <tr>
    <th align="left">ADDRESS: </th>
    <td colspan="7" align="center"><input type="text" name="address" size="111" value="<?php echo $address; ?>" disabled></td>
  </tr>
</table>

注意:我没有包含table中的所有数据

【问题讨论】:

  • 好的,我会的。谢谢

标签: html css


【解决方案1】:

假设表格可以适合单个页面,您可以使用打印媒体查询。

@print{
.table-responsive:{
height:95%;
}
}

【讨论】:

  • 哦,它确实有效。谢谢。还有一个问题,打印时如何打破表格列?
  • 我给你的搜索中的第一个链接之一。请调查一些并一次提出一个问题:stackoverflow.com/questions/26777317/…
猜你喜欢
  • 2013-10-31
  • 2020-04-18
  • 2020-04-21
  • 2022-01-18
  • 1970-01-01
  • 1970-01-01
  • 2019-10-26
  • 2013-05-26
  • 2015-03-25
相关资源
最近更新 更多