css打印分页_⾼级CSS打印-使⽤CSS分页符
css 打印分页
I have one customer that absolutely insists his web pages print perfectly. Why? Because he refuses to look at his pages on the screen -- he tells his employees to print the website for him to look at. And since he looks at pages that way, he believes most of his customers do just this.
我有⼀位客户绝对坚持他的⽹页可以完美打印。 为什么? 因为他拒绝查看屏幕上的页⾯-他告诉他的员⼯打印⽹站以供他查看。 由于他以这种⽅式查看⽹页,因此他相信⼤多数客户都这样做。
Needless to say, I've learned quite a few tricks to making a website print properly. I've already shared methods for , as well as . One important aspect of making your pages printer-friendly is by using CSS/XHTML page breaks.
不⽤说,我已经学到了很多使⽹站正确打印的技巧。 我已经分享了以及 。 使页⾯易于打印的⼀个重要⽅⾯是使⽤CSS / XHTML分页符。
There are numerous spots that are good for page breaks:
分页符有很多优点:
Between page sections (h2 or h3 tags, depending on your site format)
页⾯部分之间(h2或h3标签,取决于您的⽹站格式)
Between the end of an article and subsequent comments / trackbacks
在⽂章结尾与后续评论/引⽤之间
Between longs blocks of content
在多头内容之间
Luckily, using page breaks in CSS is quite easy.
幸运的是,在CSS中使⽤分页符⾮常容易。
CSS (The CSS)
The all and print medias should be addressed:
all和print媒体应处理:
@media all {
.page-break { display: none; }
}
@media print {
.page-break { display: block; page-break-before: always; }
}
The first declaration ensures that the page-break is never while the second ensures that the page break is seen by the printer.
第⼀个声明可确保从视觉上看不到分页符...⽽第⼆个声明可确保打印机可以看到分页符。
HTML (The HTML)
Creating a simple DIV element with the page-break class is how you implement the page break.
使⽤page-break类创建⼀个简单的DIV元素是实现分页符的⽅式。
<div class="page-break"></div>
Quite simple, huh?
很简单,对吧?
⽤法 (The Usage)
<h1>Page Title</h1>
<!-- content block -->
<!-- content block -->ignore subsequent bad blocks
<div class="page-break"></div>
<!-- content block -->
<!-- content block -->
<div class="page-break"></div>
<!-- content block -->
<!-- content -->
There you have it. The importance of page breaks in the web should not be understated, as many users still print content regularly. Also note that your content may be printed into PDF format and shared.
你有它。 ⽹络中分页符的重要性不容⼩under,因为许多⽤户仍在定期打印内容。 另请注意,您的内容可能会打印为PDF格式并共享。
翻译⾃:
css 打印分页
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论