Bootstrap grid for printing

前端 未结 11 2217
长情又很酷
长情又很酷 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:06

    If you want the Bootstrap's grid do not print with col-xs (mobile settings) , and want to use col-sm-?? instead , Based on Fredy31 answer and you don't even need to define col-print-??. simply rewrite all col-md-?? css class definitions inside a: @media print { /* copy and paste from bootstrap.css*/ } like this:

    @media print {
       .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12 {
            float: left;
       }
       .col-sm-12 {
            width: 100%;
       }
       .col-sm-11 {
            width: 91.66666667%;
       }
       .col-sm-10 {
            width: 83.33333333%;
       }
       .col-sm-9 {
            width: 75%;
       }
       .col-sm-8 {
            width: 66.66666667%;
       }
       .col-sm-7 {
            width: 58.33333333%;
       }
       .col-sm-6 {
            width: 50%;
       }
       .col-sm-5 {
            width: 41.66666667%;
       }
       .col-sm-4 {
            width: 33.33333333%;
       }
       .col-sm-3 {
            width: 25%;
       }
       .col-sm-2 {
            width: 16.66666667%;
       }
       .col-sm-1 {
            width: 8.33333333%;
       }
    }
    

提交回复
热议问题