Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to hide elements on the first page (example: footer)? #474

Closed
cymen opened this issue Jun 2, 2017 · 8 comments
Closed

Is it possible to hide elements on the first page (example: footer)? #474

cymen opened this issue Jun 2, 2017 · 8 comments
Labels
CSS Questions about how to do something with CSS

Comments

@cymen
Copy link

cymen commented Jun 2, 2017

Is it possible to hide elements on the first page of the generated PDF? I have some footer elements that repeat on every page. I would like to hide them on the first page.

I tried the @page :first selector like so:

      @page :first .footer {
        display: none;
      } 

However, running weasyprint emits:

WARNING: Parse error at 67:13, invalid @page selector

(67:13 corresponds to the above CSS)

@cymen
Copy link
Author

cymen commented Jun 2, 2017

Ah! I see that I missed this part:

The @page rule can only contain page properties and margin at-rules.

So it is logical that @page cannot support this. Is there another mechanism that might work?

@liZe liZe added the CSS Questions about how to do something with CSS label Jun 2, 2017
@MindFluid
Copy link

You can use named pages, as mentioned in this issue: #511.

If you have the ability, you could define your first page in a separate section or block, plug in its unique data, and give it a break after property.

@liZe
Copy link
Member

liZe commented Nov 6, 2018

You can use named pages, as mentioned in this issue: #511.

It's right, using named pages as explained should be enough.

@ritiksoni00
Copy link

ritiksoni00 commented Mar 27, 2022

give it a break after the property.

I'm not able to get it. can you please explain a Lil bit? @MindFluid

@movahhedi
Copy link

I'm not able to get it too. Any ideas?

@liZe
Copy link
Member

liZe commented Oct 15, 2024

I'm not able to get it too. Any ideas?

You can use named pages (or just :first for the first page) to put different things in the page margins.

@movahhedi
Copy link

How though?

This doesn't work:

@page :first .header {
    display: none;
} 

I need the first page not to have a header.

@liZe
Copy link
Member

liZe commented Oct 15, 2024

I need the first page not to have a header.

You can take a look at what’s done in the Report sample. The header is repeated on some but not all pages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CSS Questions about how to do something with CSS
Projects
None yet
Development

No branches or pull requests

5 participants