html - Make a footer but in every page different with CSS in a printed document

Html - Make a footer but in every page different with CSS in a printed document

To create a footer with different content on each printed page using CSS, you can utilize the @page rule along with the :nth-of-type() selector to target specific pages. Here's an example:

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Print Footer Example</title> <style> @page { size: A4; margin: 1cm; } /* Define different footers for odd and even pages */ @page :first { @bottom-left { content: "Footer for First Page"; } } @page :nth-of-type(2n) { @bottom-left { content: "Footer for Even Pages"; } } @page :nth-of-type(2n+1) { @bottom-left { content: "Footer for Odd Pages"; } } /* Additional styling for the footer */ @page { @bottom-left { font-size: 10px; color: #666; } } /* Print-specific styles */ @media print { /* Hide the original footer */ footer { display: none; } } </style> </head> <body> <!-- Your HTML content here --> <footer> This is the footer for the web view. </footer> </body> </html> 

In this example:

  • The @page rule defines the size and margins of the printed page. We've set it to A4 size with 1cm margins.
  • Different footers are defined for the first page, even pages, and odd pages using the @bottom-left rule inside the @page rule, specifying different content for each.
  • Additional styling for the footer is applied within the @page rule.
  • In the print-specific styles, we hide the original footer using display: none; so that only the printed footers are displayed.

You can adjust the content property within the @bottom-left rule to customize the content of each footer according to your requirements.

Examples

  1. CSS Print Media Query for Different Footers on Each Page in HTML

    • Description: Use CSS print media query to style and display different footers on each printed page of an HTML document, enhancing document organization and readability.
    @media print { @page { size: auto; margin: 5mm; } body { margin: 0; padding: 0; } footer { position: fixed; bottom: 0; width: 100%; text-align: center; } } 
  2. HTML Print Page Footer Variation with CSS

    • Description: Customize the footer appearance on each printed page of an HTML document using CSS to differentiate content and provide contextual information.
    @media print { footer:nth-of-type(odd) { background-color: #f0f0f0; color: #333; } footer:nth-of-type(even) { background-color: #ccc; color: #fff; } } 
  3. Creating Unique Page Footers for Printed HTML Documents

    • Description: Implement CSS rules to generate distinct footers for each printed page of an HTML document, improving document navigation and organization.
    @media print { footer.page1 { content: "Footer for Page 1"; } footer.page2 { content: "Footer for Page 2"; } /* Define more footers for additional pages as needed */ } 
  4. HTML Printed Document Footer Variation Using CSS Pseudo-Elements

    • Description: Utilize CSS pseudo-elements to create varying footers for each printed page of an HTML document, enhancing document structure and readability.
    @media print { footer:nth-of-type(1):after { content: "Footer for Page 1"; } footer:nth-of-type(2):after { content: "Footer for Page 2"; } /* Define more footers for additional pages as needed */ } 
  5. CSS Styling for Different Footers on Printed HTML Pages

    • Description: Style the footers of printed HTML pages using CSS to provide distinct visual cues and improve document navigation and organization.
    @media print { footer { position: fixed; bottom: 0; width: 100%; text-align: center; } footer:nth-of-type(odd) { background-color: #f0f0f0; color: #333; } footer:nth-of-type(even) { background-color: #ccc; color: #fff; } } 
  6. Dynamic Footer Content for Printed HTML Documents with CSS

    • Description: Dynamically generate footer content for each printed page of an HTML document using CSS to enhance document context and readability.
    @media print { footer { position: fixed; bottom: 0; width: 100%; text-align: center; counter-increment: page; content: "Footer for Page " counter(page); } } 
  7. HTML Printed Document Footer Variation Based on Content

    • Description: Customize footers for printed HTML documents based on content using CSS to provide relevant information and improve document comprehension.
    @media print { .section1 footer { content: "Footer for Section 1"; } .section2 footer { content: "Footer for Section 2"; } /* Define more footers for additional sections as needed */ } 
  8. CSS Styling for Different Printed Page Footers in HTML

    • Description: Style footers for each printed page of an HTML document using CSS to enhance document aesthetics and organization for better readability.
    @media print { footer { position: fixed; bottom: 0; width: 100%; text-align: center; } @page :first { footer { content: "First Page Footer"; } } @page :not(:first) { footer { content: "Footer for Subsequent Pages"; } } } 
  9. CSS Styling for Different Printed Document Footers

    • Description: Implement CSS rules to style different footers for each printed page of an HTML document, improving document structure and navigation.
    @media print { footer.page1 { content: "Footer for Page 1"; } footer.page2 { content: "Footer for Page 2"; } /* Define more footers for additional pages as needed */ } 
  10. HTML Printed Document Footer Variation Based on Page Number

    • Description: Customize footers for printed HTML documents based on page number using CSS to provide contextual information and improve document clarity.
    @media print { footer { position: fixed; bottom: 0; width: 100%; text-align: center; content: "Page " counter(page); } } 

More Tags

immutability brokeredmessage bokeh ckeditor5 spring-data-mongodb onbackpressed backslash jquery-ui-dialog fire-sharp transpose

More Programming Questions

More Pregnancy Calculators

More Stoichiometry Calculators

More Math Calculators

More Mortgage and Real Estate Calculators