我的网页中有一个动态表,有时包含很多行。我在 22 行后进行了分页。我需要在新页面中重复某些表(信息表,见图片)。我怎么做?
图像 https://i.ibb.co/LN8gVbD/Screen-Shot-2019-05-26-at-03-34-26.png
另一件事,我无法在 Chrome 中实现分页。它只适用于 Firefox,如何在 Chrome 中修复它?
<style type="text/css">
#receipt-data { font-size: 12px; }
@media print {
tr.page-break{
page-break-inside: avoid;;
page-break-before:always;
}
@page {
size:portrait;
}
}
</style>
<div id="receipt-data">
<table class="table hed">
<thead style="text-align:center;">
<tr style="text-align:center;">
<th colspan="1">Name</th>
<th colspan="2">{{$customer_data->name}}i</th>
<th colspan="1">Customer Tax No</th>
<th colspan="2">{{$customer_data->tax_no}}</th>
</tr>
</thead>
</table>
<table class="table table-bordered" style="text-align:center;">
<thead>
<tr>
<th>S</th>
<th>Item Code</th>
<th>Description</th>
<th>Unit</th>
<th>Unit Price</th>
<th>Qty</th>
<th>Amount($)
</th>
</tr>
</thead>
<tbody>
@foreach($product_sale_data as $key=>$product_sale_data)
@php
$product_data = \App\Product::find($product_sale_data->product_id);
if($product_data->sale_unit_id)
$unit = \App\Unit::find($product_data->sale_unit_id)->unit_name;
else
$unit = 'N/A';
@endphp
<tr class = @if ( $key % 22 == 0 && $key ) "page-break" @endif>
<td>{{$key+1}}</td>
<td>{{$product_data->code}}</td>
<td>{{$product_data->name}}</td>
<td>{{$unit}}</td>
<td>{{number_format($product_sale_data->total / $product_sale_data->qty, 2)}}</td>
<td>{{$product_sale_data->qty}}</td>
<td>{{number_format($product_sale_data->total, 2)}}</td>
@endforeach
<br>
最佳答案
注意:如果 $key
值以 0 开头然后低于 <thead>
不需要,但如果$key
以 1 开头然后下面需要一次不需要循环 foreach
<thead>
<tr>
<th>S</th>
<th>Item Code</th>
<th>Description</th>
<th>Unit</th>
<th>Unit Price</th>
<th>Qty</th>
<th>Amount($)
</th>
</tr>
</thead>
@foreach($product_sale_data as $key=>$product_sale_data)
@if ( $key % 22 == 0 && $key ) // so here every 22 rows after this will go
<thead>
<tr>
<th>S</th>
<th>Item Code</th>
<th>Description</th>
<th>Unit</th>
<th>Unit Price</th>
<th>Qty</th>
<th>Amount($)
</th>
</tr>
</thead>
@endif
<tbody>
@php
$product_data = \App\Product::find($product_sale_data->product_id);
if($product_data->sale_unit_id)
...continue your code
关于php - 如何在新的分页符中重复表头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56310293/