0

It been a while that i'm looking for a solution to print fixed header and footer on multipage document, ive finally made it work but still have a little problem.

The problem is that the width of my tds dont follow my ths :( and i get a disorder table.

This is my html code :

<table>
  <thead>
      <tr>
          <td>
              <div class="header-space">
              </div>
          </td>
      </tr>
  </thead>
  <tfoot>
    <tr>
      <td>
        <div class="footer-space"></div>
      </td>
    </tr>
  </tfoot>
  <tbody>
    <tr>
      <td>
        <div class="content">
            <tr>
              <td>Value A</td>
              <td>Value B</td>
              <td>Value C</td>
              <td>Value D</td>
              <td>Value E</td>
              <td>Value F</td>
              <td>Value G</td>
            </tr>
            <tr></tr>
            ...
        </div>
      </td>
    </tr>
  </tbody>
</table>
<div class="footer">
  <p>FOOTER CONTENT</p>
</div>
<div class="header">
  <tr>
    <th>A</th>
    <th>B</th>
    <th>C</th>
    <th>D</th>
    <th>E</th>
    <th>F</th>
    <th>G</th>
  </tr>
  <tr></tr>
  ...
</div>
<style>
.header, .header-space {
    height: 280px;
    width: 100%;
}
.footer, .footer-space {
  height: 50px;

}

.header {
  position: fixed;
  top: 0;
}

.footer {
  position: fixed;
  bottom: 0;
}
</style>

Thank you for reading my post ! Good day

Imbrah
  • 1
  • 1

1 Answers1

0

Sorry if my comments came as a bit harsh.
If you want to have a fixed header and footer and the table scroll between them then see the solution on the other stack post or this fiddle http://jsfiddle.net/T9Bhm/7 which comes down to

  tbody {
            height: 120px;
            overflow-y: auto;
        }

Why is the header formed with <tr> but outside the table? If you put it inside the <table> tag it will take over the same width as <td>

mrQubeMaster
  • 342
  • 2
  • 14