HTML Header and footer in all pages while printing html document

后端 未结 4 809
甜味超标
甜味超标 2021-01-18 05:57

I\'ve created a html page with a header,some content and a footer. I tried to get a print of the HTML page, and there was 2 pages. I got the header in first page and the foo

4条回答
  •  余生分开走
    2021-01-18 06:22

    Use fixed positioned elements that you activate with print media type:

    #header, #footer {
         display: none;
    }
    @media print
    {
        #header, #footer {
             position: fixed;
             display: block;
             top: 0;
        }
        #footer {
             bottom: 0;
        }
    }
    

    (Here assuming you have div elements with id header and footer).

提交回复
热议问题