Detecting printed page size with CSS media queries

后端 未结 1 1669
长情又很酷
长情又很酷 2021-02-05 12:12

My app generates printed reports by creating an invisible iframe and then printing it. My latest in a depressingly long list of problems I\'m trying to solve is optimizing the

相关标签:
1条回答
  • 2021-02-05 12:30

    Just try this code May be this can fixed your problem.

    <page size="A4"></page>
    

    Css

    @page {
      size: A4;
      margin: 0;
    }
    page {
      background: white;
      display: block;
      margin: 0 auto;
      margin-bottom: 12px;
      box-shadow: 0 0 5px rgba(0,0,0,0.5);
    }
    page[size="A4"] {  
      width: 210mm;
      height: 297mm; 
    }
    
    @media print {
      body {
        margin: 0;
        box-shadow: 0;
        background: rgb(204,204,204); 
      }
    }
    
    0 讨论(0)
提交回复
热议问题