Media queries for landscape printing?

前端 未结 2 946
情书的邮戳
情书的邮戳 2021-01-02 08:17

I\'ve got some styles specifically for print, which are being applied correctly with a print media query. The thing is, my layout breaks a bit if you switch to landscape pri

相关标签:
2条回答
  • 2021-01-02 08:37

    Media Queries offer matching against the device's orientation:

    @media print and (orientation: landscape) {
        /* landscape styles */
    }
    
    @media print and (orientation: portrait) {
        /* portrait styles */
    }
    
    0 讨论(0)
  • 2021-01-02 08:51
    <style>
        @media print {
            @page {
                size: landscape; /*automatically set to Landscape only*/
            }
        }
    </style>
    

    If you want letting the user to choose between the two ways : portrait/Landscape, do :

     <style type="text/css" media="print">
            @page {
                /* portrait/Landscape */
                size: auto;
               /*adding some margins to let the title and the date to be displayed*/
                margin: 40px 10px 35px; 
            }
      </style>
    
    0 讨论(0)
提交回复
热议问题