打印样式:如何确保图像不跨越分页符
在编写打印样式表时,有没有办法确保图像始终仅在单个页面上,而不是跨越多个页面。图像比页面小得多,但根据文档流,它们最终位于页面底部并被分割。我所看到的行为示例如下:
Page 1 | |
| (text text text) |
| (text text text) |
| ________________ |
| | Top of image | |
|____________________|
------page break------
____________________
Page 2 | | Rest of image | |
| |________________| |
| … |
我想要什么
Page 1 | |
| (text text text) |
| (text text text) |
| |
| |
|____________________|
------page break------
____________________
Page 2 | ________________ |
| | Full image | |
| | | |
| |________________| |
| … |
我一直在抱怨 LaTeX 中的浮动,而在这里我要求相同的功能...这可以做到吗?我不一定关心它在所有浏览器中的工作情况,因为这通常只是我正在编写的要转换为 PDF 的一次性文档。
When writing a print stylesheet, is there a way to ensure that an image is always only on a single page, instead of spanning multiple pages. The images much smaller than the page, but based on the document flow, they end up at the bottom of the page and get split. An example of the behavior I'm seeing is below:
Page 1 | |
| (text text text) |
| (text text text) |
| ________________ |
| | Top of image | |
|____________________|
------page break------
____________________
Page 2 | | Rest of image | |
| |________________| |
| … |
What I'd like
Page 1 | |
| (text text text) |
| (text text text) |
| |
| |
|____________________|
------page break------
____________________
Page 2 | ________________ |
| | Full image | |
| | | |
| |________________| |
| … |
All those times I complained about floats in LaTeX, and here I am asking for the same functionality... Can this be done? I'm not necessarily concerned about it working in all browsers, since this is often just a one-off document I'm writing to be turned into a PDF.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能想到的唯一方法是使用以下 css 规则中的一个(或可能多个):
我记得这些声明仅适用于块级元素(因此您还必须定义
display: ;
在你的图像上,或者使用某种包装容器并应用规则(无论是在段落、div、span、列表等中......)。block href="https://stackoverflow.com/questions/2226939/what-are-most-useful-mediaprint-specfic-cross-browser-company-css-properti">什么是最有用的
media="print"
特定的、跨浏览器兼容的 CSS 属性?”参考:
分页后
。page-break-before
。page-break-inside
。The only means I can think of is to use one (or potentially more) of the following css rules:
I half-recall that these declarations only apply to block-level elements (so you'd also have to define
display: block;
on your image, or use some kind of wrapping container and apply the rules to that (whether it's in a paragraph, div, span, list, etc...).Some useful discussion here: "What are most usefule
media="print"
specific, cross-browser compatible CSS properties?"References:
page-break-after
.page-break-before
.page-break-inside
.