Оновлено: 19.05.2025
@page
@page
Правило @page дає змогу задати значення полів під час друку документа або для сторінок, у яких тип носія задано як print.
Синтаксис
@page [ { :left | :right | :first } ] { ... }
Значення
Для встановлення полів на сторінці використовується універсальна властивість margin або її похідні - margin-top, margin-right, margin-bottom і margin-left, які задають відповідно відступ зверху, праворуч, знизу і зліва. Негативне значення допускається, але частина сторінки може виявитися "відрізаною". Властивості border і padding не застосовуються.
Ключове слово :left дає змогу задати поля для всіх лівих сторінок, :right - для всіх правих, а :first - для першої сторінки.
Приклад
<!DOCTYPE html>
<html>
<head>
<metacharset="utf-8">
<title>@page</title>
<link rel="stylesheet" href="/example/css/print.css" media="print">
</head>
<body>
<h1>The method of catching a lion in the desert</h1>
<h2>Sequential iteration method</h2>
<p>Let the lion have overall dimensions LxWxH, where L is the length of the lion from the tip of the nose
to the tassel of the tail, W is the width of the lion, and H is its height. Then we divide the desert into
a series of elementary rectangles, the size of which coincides with the width and length of the lion.
Given that the lion may not be strictly on a given area, but at the same time on
two of them, the cage for catching should be made with an increased area, namely 2Lx2W.
Thanks to this, we will avoid the error when only half of the
a lion or, worse, only his tail.</p>
<p>Next, successively cover each of the marked rectangles of the desert
cage and check if the lion is caught or not. Once the lion is in the cage, the procedure
the capture is considered complete.</p>
</body>
</html>