0

I'm creating some content with HTML/CSS and when previewing it in the printer dialogue, only the first pages looks "good".

The second and subsequent pages have an initial space in the top that pushes the content to two pages.

Does anyone have a clue what this might be?

Here's the code:

Just put that in a .html file and open in Chrome and "Print-Preview" it.

<html>
    <head>
        <meta charset="UTF-8" />
        <style>
        html{font-family: Avenir-Book;}
        h1{font-size: 16px;}
        @page {size: A3; margin: 0mm 0mm 0mm 0mm;}
        @media print {
          .month{
            page-break-after: always;
          }
        }
        .header{-webkit-print-color-adjust: exact;height: 30%;background-color: red !important;}
        .content{-webkit-print-color-adjust: exact;height: 70%;background-color: blue !important;}
        table{table-layout: fixed;height: 100%;width: 100%;}
        .header h1{color: #74cc82;position: relative;transform: translateY(-50%);-webkit-transform: translateY(-50%);top: 50%;font-size: 1200%;}
        tr{height: 40px;}
        th{font-size: 175%;}
        td{font-size: 400%;text-align: center;}
        th, td{color: #1a4567;}
        td:last-child, th:last-child{color: #74cc82;}
        </style>
    </head>
    <body>
        <div class="month" style="background-color: red;" >
            <div class="header" >
                <h1 align="center" >
                    Janvier
                </h1>
            </div>
            <div class="content" >
                <table>
                    <tr>
                        <th>L</th>
                        <th>M</th>
                        <th>M</th>
                        <th>J</th>
                        <th>V</th>
                        <th>S</th>
                        <th>D</th>
                    </tr>
                    <tr>
                        <td>1</td>
                        <td>2</td>
                        <td>3</td>
                        <td>4</td>
                        <td>5</td>
                        <td>6</td>
                        <td>7</td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="month" style="background-color: red;" >
            <div class="header" >
                <h1 align="center" >
                    Janvier
                </h1>
            </div>
            <div class="content" >
                <table>
                    <tr>
                        <th>L</th>
                        <th>M</th>
                        <th>M</th>
                        <th>J</th>
                        <th>V</th>
                        <th>S</th>
                        <th>D</th>
                    </tr>
                    <tr>
                        <td>1</td>
                        <td>2</td>
                        <td>3</td>
                        <td>4</td>
                        <td>5</td>
                        <td>6</td>
                        <td>7</td>
                    </tr>
                    <tr>
                        <td>8</td>
                        <td>9</td>
                        <td>10</td>
                        <td>11</td>
                        <td>12</td>
                        <td>13</td>
                        <td>14</td>
                    </tr>
                </table>
            </div>
        </div>
    </body>
</html>
netdigger
  • 3,659
  • 3
  • 26
  • 49
  • We would it be closed? It's the very similar to questions like: https://stackoverflow.com/questions/1960939/disabling-browser-print-options-headers-footers-margins-from-page/2780518#2780518 or https://stackoverflow.com/questions/1542320/margin-while-printing-html-page?noredirect=1&lq=1 – netdigger Sep 15 '18 at 11:43
  • Questions seeking debugging help must include the shortest code necessary to reproduce it **within the question itself**. [mcve] A link to your github is insufficient as, when it gets fixed or goes dead, will make your question and the answers useless. – Rob Sep 15 '18 at 12:03
  • @Rob Ok - fixed it – netdigger Sep 15 '18 at 12:17

0 Answers0