CSS paged media :last page selector

后端 未结 2 1437
悲哀的现实
悲哀的现实 2020-12-19 15:20

I need to know if I can modify content on the last page with the :last selector.

I\'m not sure if it exists, I see it being used in other stackoverflow a

2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-19 16:10

    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

    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.

提交回复
热议问题