html - page-break-before: always is freezing print dialog box -


i have html page generates bunch of tables. need see page on screen able print it. when print, want make sure each table begins in new piece of paper.

to accomplish using page-break-before: always css rule h4 tag. however, causing print dialog freeze before loading preview , way out close tab.

does know why may happening , how around it. if there better approach printing something, i'd know well. thanks!

here code:

show.html.erb

<html> 

<html>  <head>    <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.13/css/jquery.datatables.min.css">      <link rel="stylesheet" type="text/css" media="print" href="print.css">    </head>    <body>    <!-- table page -->                <% @reports.each |report| %>      <% next if report[1].empty? %>      <div class="page-tables">      <!-- table -->      <div class="table-responsive">                          <h4><%= report[0] %></h4>        <table class="table table-hover table-bordered table-striped">          <thead>          <th><%= report[0] %></th>            <tr>                <th>name</th>                <th>other columns</th>                           </tr>          </thead>          <tbody>            <% report[1].each |line| %>            <tr>                <td><%= line[0] %></td>                <td>other columns</td>          </tr>            <% end %>          </tbody>                 </table>        <br>         <% end %>        <div class="clearfix"></div>      </div>    </div>  </body>

and .css files

@media print {    h4{    page-break-before: always;  }        tr:nth-child(even) td {      background-color: #e2e1e1 !important;    }          }

things i've noticed: - when reduce number of tables generated in report, no freezing happens - if keep high number of tables remove css rule page-break-before:always there no freezing - striped css rule not causing issues

other notes, not sure if relevant: - developing on chrome - end rails app -there 20 tables, average of 20 rows each. loading fine on screen. issue when cmd+p print

i think causing issue </div> closing tags after <%end%> erb tag. fixed , works now.

<html>  <head>    <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.13/css/jquery.datatables.min.css">      </head>    <body>    <!-- table page -->      <% @reports.each |report| %>      <% next if report[1].empty? %>      <div class="page-tables break-before-table">      <!-- table -->        <div class="table-responsive">          <h4><%= report[0] %></h4>          <table class="table table-hover table-bordered table-striped">            <thead>              <th colspan="11"><%= report[0] %></th>                <tr>                  <th>name</th>                                  </tr>            </thead>            <tbody>              <% report[1].each |line| %>                <tr>                  <td><%= line[0] %></td>                                  </tr>              <% end %>            </tbody>          </table>          <br>        </div>      </div>      <% end %>       </body>


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -