Bootstrap grid for printing

前端 未结 11 2240
长情又很酷
长情又很酷 2020-12-23 11:25

I would like to design a report page with a different layout for printing to mobile. I am using bootstrap v3. It seems the grid can\'t differentiate between the two as the b

11条回答
  •  别那么骄傲
    2020-12-23 12:16

    Instead of recreating with new column names like .col-print-1 , .col-print-2 , write a media query which will be enable while printing the document.

      @media print {
      .col-md-1,.col-md-2,.col-md-3,.col-md-4,
      .col-md-5,.col-md-6,.col-md-7,.col-md-8, 
      .col-md-9,.col-md-10,.col-md-11,.col-md-12 {
        float: left;
      }
    
      .col-md-1 {
        width: 8%;
      }
      .col-md-2 {
        width: 16%;
      }
      .col-md-3 {
        width: 25%;
      }
      .col-md-4 {
        width: 33%;
      }
      .col-md-5 {
        width: 42%;
      }
      .col-md-6 {
        width: 50%;
      }
      .col-md-7 {
        width: 58%;
      }
      .col-md-8 {
        width: 66%;
      }
      .col-md-9 {
        width: 75%;
      }
      .col-md-10 {
        width: 83%;
      }
      .col-md-11 {
        width: 92%;
      }
      .col-md-12 {
        width: 100%;
      }
    }
    

    So by this way we can be able to apply print css styles directly without changing the column names.

提交回复
热议问题