@page

@page@规则CSS用于打印document. 您不能改变所有的CSS属性时,修改一些CSS属性@page。您只能更改文档的margins, orphans, widows 和分页符。试图改变任何其他的CSS属性将被忽略。

@page {
  margin: 1cm;
}

@page :first {
  margin: 2cm;
}

@page@规则可以通过CSS对象模型的接口来访问CSSPageRule

注: W3C正在讨论如何处理视相关<length>单位vhvwvmin,和vmax。同时不要@page在规则中使用它们。

语法

描述符

size指定页面框包含块的目标大小和方向。在一般情况下,一个页面框被渲染到一个页面页面上,它也指示目的地页面页面的大小。marks在文档中添加作物和/或注册标记。bleed指定页面呈现被剪辑的页面框之外的范围。

形式语法

@page <page-selector-list> {
  <page-body>
}where 
<page-selector-list> = [ <page-selector># ]?
<page-body> = <declaration>? [ ; <page-body> ]? | <page-margin-box> <page-body>
where 
<page-selector> = <pseudo-page>+ | <ident> <pseudo-page>*
<page-margin-box> = <page-margin-box-type> {
  <declaration-list>
}
where 
<pseudo-page> = : [ left | right | first | blank ]
<page-margin-box-type> = @top-left-corner | @top-left | @top-center | @top-right | @top-right-corner | @bottom-left-corner | @bottom-left | @bottom-center | @bottom-right | @bottom-right-corner | @left-top | @left-middle | @left-bottom | @right-top | @right-middle | @right-bottom

实例

请参阅伪类成@page举个例子。

  • :first
  • :left
  • :right

规范

Specification

Status

Comment

CSS Logical Properties Level 1The definition of ':recto and :verso' in that specification.

Editor's Draft

Adds the :recto and :verso page selectors

CSS Paged Media Module Level 3The definition of '@page' in that specification.

Working Draft

No change from CSS Level 2 (Revision 1), though more CSS at-rules can be used inside a @page.

CSS Level 2 (Revision 1)The definition of '@page' in that specification.

Recommendation

Initial definition

浏览器兼容性

Feature

Chrome

Edge

Firefox (Gecko)

Internet Explorer

Opera

Safari

Basic support

2.0

(Yes)

19.0 (19.0)

8.0

6.0

No support

Feature

Android

Edge

Firefox Mobile (Gecko)

IE Mobile

Opera Mobile

Safari Mobile

Basic support

?

(Yes)

19.0 (19.0)

?

?

?

扫码关注云+社区

领取腾讯云代金券