Printing Twitter Bootstrap correctly

后端 未结 1 1801
独厮守ぢ
独厮守ぢ 2020-12-07 14:52

I\'m really struggeling to print my Twitter Bootstrap views correctly, and was wondering if anyone could point me in the right direction. I\'ve added a custom \"print.css\"

相关标签:
1条回答
  • 2020-12-07 15:31

    Firstly Bootstrap.css does come with pre-defined print styles such as:

    /** 
     *  Use these for toggling content for print.
    **/
    .visible-print {
        display: block !important;
    }
    
    .hidden-print {
        display: none !important;
    }
    

    Secondly you can test with page-break css rule to separate the charts onto different pages for cleaner formatting.

    /** 
     *  Page-break-inside seems to
     *  be required for Chrome.
    **/
    div.somechart { 
       page-break-after: always; 
       page-break-inside: avoid;
    }
    

    Third test with formatting with the rows to take up the full width on print screen rather than relying on percentages of the span3/col-*-3's and span4/col-*-4's, because it would seem they are behaving correctly in some way when you take into account:

    • Sytem printing page margins
    • Bootstrap's @print defined margins
    • Page gutters
    • span percentages at print screen.

    Finally the last small thing that's helpful to note (Yes, despite the custom @print style!):

    <link href="/assets/css/bootstrap.min.css" rel="stylesheet" media="screen" />
    

    to:

    <link href="/assets/css/bootstrap.min.css" rel="stylesheet" media="all" />
    
    0 讨论(0)
提交回复
热议问题