Margin while printing html page

后端 未结 6 1203
栀梦
栀梦 2020-11-28 01:17

I am using a separate style-sheet for printing. Is it possible to set right and left margin in the style-sheet which set the print margin (i.e. margin on paper).

Tha

6条回答
  •  借酒劲吻你
    2020-11-28 01:43

    Updated, Simple Solution

    @media print {
       body {
           display: table;
           table-layout: fixed;
           padding-top: 2.5cm;
           padding-bottom: 2.5cm;
           height: auto;
       }
    }
    

    Old Solution

    Create section with each page, and use the below code to adjust margins, height and width.

    If you are printing A4 size.

    Then user

    Size : 8.27in and 11.69 inches

    @page Section1 {
        size: 8.27in 11.69in; 
        margin: .5in .5in .5in .5in; 
        mso-header-margin: .5in; 
        mso-footer-margin: .5in; 
        mso-paper-source: 0;
    }
    
    
    
    div.Section1 {
        page: Section1;
    } 
    

    then create a div with all your content in it.

    type your content here...

提交回复
热议问题