始终在 <h1> 元素之前插入分页符:
@media print {
h1 {
break-before: always;
}
}
这个break-before
属性指定在指定元素之前是否应出现分页符、列符或区域符。
这个break-before
属性扩展了CSS2 page-break-before
属性。
使用break-before
,您可以告诉浏览器在元素之前打破页面、列或区域break-before
属性应用于,或避免元素被拆分并跨越两个页面。
默认值: | 汽车 |
---|---|
遗传: | 不 |
可动画: | 不。阅读可动画的 |
版本: | CSS3 |
JavaScript 语法: | 对象.style.breakBefore="always" |
表中的数字指定完全支持该属性的第一个浏览器版本。
Property | |||||
---|---|---|---|---|---|
break-before | 50.0 | 10.0 | 65.0 | 10.0 | 37.0 |
break-before: auto|all|always|avoid|avoid-column|avoid-page|avoid-region|column|left|page|recto|region|right|verso|initial|inherit;
Value | Description |
---|---|
auto | Default. Automatic page/column/region break before the element |
all | Always insert a page-break right before the principal box |
always | Always insert a page-break before the element |
avoid | Avoid a page/column/region break before the element |
avoid-column | Avoid a column-break before the element |
avoid-page | Avoid a page-break before the element |
avoid-region | Avoid a region-break before the element |
column | Always insert a column-break before the element |
left | Insert one or two page-breaks before the element so that the next page is formatted as a left page |
page | Always insert a page-break before the element |
recto | Insert one or two page-breaks before the principal box so that the next page is formatted as a recto page |
region | Always insert a region-break before the element |
right | Insert one or two page-breaks before the element so that the next page is formatted as a right page |
verso | Insert one or two page-breaks before the principal box so that the next page is formatted as a verso page |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
为了确保所有新章节在打印时都应从正确的页面开始(就像在书中一样),您可以对所有 <h1> 元素使用 break-before: right :
@media print {
h1 {
break-before: right;
}
}
始终在区域中的 <ul> 元素之前插入区域分隔符:
.region ul {
break-before: region;
}
}
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!