如何在打印时调整CSS中的表格或内容?

时间:2016-09-04 15:31:49

标签: html css

所以我有这个庞大的数据表,当我用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

中包含所有数据

1 个答案:

答案 0 :(得分:0)

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

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