CSS paged media :last page selector

落爺英雄遲暮 提交于 2019-12-06 07:32:33

Based on the CSS3 Page docs it appears the :last pseudo-class was removed (or never included).

It might be possible to target the last page using the :blank pseudo-class if you can force a page break at the end of your document. This might have unwanted effects on other blank pages though.

This can be achieved using named pages.

Create an element on the last page (or use an existing one that will appear on the last page) and assign it a last-page class.

Example below:

HTML

<div class="last-page"></div> <!-- Or add this class name to an existing element that appears on the last page -->

CSS

.last-page {
    page: last_page;
    page-break-before: always; /* Use if your last page is blank, else omit. */

@page {
   @bottom-right {
       content: "Please turn over";
    }
}

@page last_page {
    @bottom-right {
        content: none;
    }
}

Tested with Weasyprint - worked a charm.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!