在第二个打印页面上为表格添加边距

时间:2017-06-09 11:11:51

标签: html css

我在桌子上添加适当的边距时遇到问题,当桌子在打印时分成几页时。

以下是代码:



window.print(); //just for printing preview

body {
  -webkit-print-color-adjust: exact; //to show header color while printing
}

table {
  border-collapse: collapse;
  margin-top:2cm;
}

table,
th,
td {
  border: 1px solid black;
}

.myHeader{
  margin-left: 2cm;
  position: fixed;
  top:0;
  left:0;
  margin:0;
  background:yellow;
}

<div class="myHeader">
myHeader
</div>

<table class="myTable">
  <thead>
    <tr>
      <th>something</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
    <tr>
      <td>
        row
      </td>
    </tr>
  </tbody>
</table>
&#13;
&#13;
&#13;

问题是我想在每个页面添加标题,但是在第二页上表格没有应用保证金。

我怎么能达到这个目的?

0 个答案:

没有答案