css - 打印文档中未保留填充
问题描述
我正在尝试创建用于在 Firefox 中打印文档的 css 样式。我想要一些内容,放置在容器内,顶部和底部的间距相等。
为此,我添加了一个具有顶部和底部填充的容器,并在其中放置了一些内容:
<div class="container" style="padding: 1cm 0; box-decoration-break: clone"> ...some content ("div", "p" elements) </div>
现在,Firefox 支持box-decoration-break css 属性(允许在容器“命中”分页符时重复边框/填充/边距)。
我正在为容器设置“ box-decoration-break: clone ”并期望发生以下行为:
Printed page 1:
------------
| | <- correct spacing
| content |
| content |
| | <- correct spacing
------------
Printed page 2:
------------
| | <- correct spacing
| content |
| content |
| | <- correct spacing
------------
实际上,这正在发生:
Printed page 1:
------------
| | <- correct spacing
| content |
| content |
| content | <- (!) incorrect spacing, content "ignores" parent padding
------------
Printed page 2:
------------
| | <- correct spacing
| content |
| |
| |
------------
我可以使内容尊重父元素填充的唯一方法是将容器的所有子元素设置为“显示:内容”(这会破坏所有其他样式并使其看起来很难看)
我想就以下问题获得帮助:
1)在打印文档的特定容器内创建填充的正确方法是什么?
2)为什么我的方法不起作用?
谢谢
解决方案
推荐阅读
- environment-variables - Gatsby:在 html.js 中设置读取环境变量
- facebook-messenger - One-time notification message_optins callback not being received by testers, is being received by administrator
- teradata - 字符串转换为数值失败:Teradata 插入
- c# - 从扩展 HttpClient 的类中使用 GetAsync 时如何模拟它?
- bash - 在 Bash 中迭代这个数组
- unit-testing - 有没有办法使用Vue从url动态加载图像?
- android - 对每个 DB 条目执行请求
- python - 虽然我的电脑上已经安装了表格,但每次运行下面的代码时都会出现错误
- ls - !ls -aF 与 !ls -af 之间的区别
- c# - 带有 .NET 5 rc1 blazor Web 程序集的 Serilog 无法正常工作