CSS @page 規則
- 上一頁 padding-top
- 下一頁 page-break-after
定義和用法
CSS @page
規則用于自定義打印頁面的尺寸、方向和邊距。
實例
自定義打印頁面:
@page :first { margin-left: 40%; margin-top: 50%; } @page :left { margin-left: 10%; margin-top: 10%; } @page :right { margin-left: 90%; margin-top: 90%; }
CSS 語法
@page { margin: value; page-orientation: value; size: value; }
屬性值
值 | 描述 |
---|---|
margin | 指定頁面外邊距。 |
page-orientation | 指定頁面的方向。 |
size | 指定頁面框包含塊的目標尺寸和方向。 |
瀏覽器支持
表格中的數字表示首個完全支持該 @ 規則的瀏覽器版本。
At-rule | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
@page | 2 | 12 | 19 | No | 6 |
@page: size | 15 | 79 | 95 | No | 15 |
@page: page-orientation | 85 | 85 | No | No | 71 |
@page: @top-left | 131 | 不支持 | 不支持 | 不支持 | 不支持 |
@page: @left-top | 131 | 不支持 | 不支持 | 不支持 | 不支持 |
@page: @top-right | 131 | 不支持 | 不支持 | 不支持 | 不支持 |
@page: @right-top | 131 | 不支持 | 不支持 | 不支持 | 不支持 |
@page: @top-center | 131 | 不支持 | 不支持 | 不支持 | 不支持 |
@page: @bottom-left | 131 | 不支持 | 不支持 | 不支持 | 不支持 |
@page: @left-bottom | 131 | 不支持 | 不支持 | 不支持 | 不支持 |
- 上一頁 padding-top
- 下一頁 page-break-after