Home  >  Article  >  Web Front-end  >  Control pagination using CSS

Control pagination using CSS

WBOY
WBOYforward
2023-08-25 10:57:02672browse

使用 CSS 控制分页

To control paging, use page-break-before, page-break-after and page- break- Inside the attribute.

page-break-before and page-break-after both accept auto, always, and avoid the left and right keywords. The

keyword auto is the default; it allows the browser to generate page breaks as needed. The keyword always forces pagination before or after an element, while avoid prohibits pagination immediately before or after an element. Left and Right keyword forces one or two page breaks so that elements are rendered on the left or right side of the page.

Using the pagination attribute is very simple. Let's say your document has level 1 headings, and you represent chapters by starting new sections with level 2 headings. You want each chapter to start on a new right-hand page, but you don't want a page break to separate the chapter title from the content that follows.

Example

You can achieve this using the following rules

<style>
   <!--
      h1 {
         page-break-before : right
      }
      h2 {
         page-break-after : avoid
      }
   -->
</style>

The above is the detailed content of Control pagination using CSS. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete