html - 循环数据时如何设置打印预览的页面
问题描述
这是我的打印预览页面,您可以看到数据循环到下一页。我应该怎么做,然后数据将在同一页面中循环?
比如下图就是我想做的布局,数据会在同一个页面循环,如果满了就开始循环到下一页
我的打印页面代码
<!DOCTYPE html>
<html>
<head>
<title>This is a print page!</title>
</head>
<style>
</style>
<body>
@foreach ($xyprintPreview as $item)
<h1>{{ $item->xy_sx_ID}}</h1>
@endforeach
</body>
</html>
新更新的图片
新更新的编码
<body>
<table class="report-container" style="width: 100%">
<thead class="report-header">
<tr>
<th class="report-header-cell">
<div class="header-info mt-3">
<h4 style="text-align: center;">
<img src="https://scontent.fmkz1-1.fna.fbcdn.net/v/t31.0-8/o.jpg?_nc_cat=111&ccb=2&_nc_sid=09cbfe&_nc_ohc=gLnsAI4ON1MAX98YpzP&_nc_ht=scontent.fmkz1-1.fna&oh=bacd1bd15cf7a118af57abe52bf7e07e&oe=5FFAAEC0" alt="Avatar" style="width:60px">
柔佛古庙许愿灯登记名单({{$year}}年)
</h4>
<hr style="border: 1px solid;">
<b style="margin-left: 180px; font-size: 20px">善信编号 名字</b>
<b style="margin-left: 290px; font-size: 20px">善信编号 名字</b>
<b style="margin-left: 290px; font-size: 20px">善信编号 名字</b>
</div>
</th>
</tr>
</thead>
<tfoot class="report-footer">
<tr>
<td class="report-footer-cell">
<div class="footer-info mb-3">
</div>
</td>
</tr>
</tfoot>
<tbody class="report-content ">
<tr>
<td class="report-content-cell">
<div class="main" style="column-count:3; margin-left: 180px;">
@foreach($xyprintPreview as $item)
<ul>
<li>
<span style="font-size: 20px"><b>{{$item->xy_sx_ID}}</b> {{$item->xylight_label}}</span>
</li>
</ul>
@endforeach
</div>
</td>
</tr>
</tbody>
第2页
解决方案
css 属性column-count
可以解决你的问题。附加到包含 h1 标签或 ul li 标签的 div 标签。
<div style="column-count: 3;">
</div>
它将这个 div 中的内容分成三列,具有相同的页面。你可以看到演示(jsfiddle)
您可以使用 ul, li 标签将项目符号样式删除为 none 以获得有序结果。你可以看到演示(jsfiddle)
推荐阅读
- django - 在 django 表中使用字段作为行
- java - Kafka 主题未收到来自发布者发送()的一些记录
- javascript - 使用 ClientScript SS2.0 在 SUITELET 中创建事件
- javascript - 如何合并两个数组中的对象
- eclipse - 在 Eclipse(Mac 上为 2019-06)中看不到服务器选项卡选项卡以添加 Tomcat 服务器
- vue.js - Vue、Leaflet、Mapbox - 找不到错误地图容器
- vue.js - 单击已选择的树项时如何停止 Vuetiify v-treeview 取消选择?
- swift - 用户返回上一页时如何隐藏导航栏阴影(快速)
- javascript - 使用 addEventListener 时出现未定义错误
- wordpress - 如何在登录时更改 WooCommerce 角色?