Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Render Bootstrap as "small" layout when printing
@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%;
}
.col-sm-pull-12 {
right: 100%;
}
.col-sm-pull-11 {
right: 91.66666667%;
}
.col-sm-pull-10 {
right: 83.33333333%;
}
.col-sm-pull-9 {
right: 75%;
}
.col-sm-pull-8 {
right: 66.66666667%;
}
.col-sm-pull-7 {
right: 58.33333333%;
}
.col-sm-pull-6 {
right: 50%;
}
.col-sm-pull-5 {
right: 41.66666667%;
}
.col-sm-pull-4 {
right: 33.33333333%;
}
.col-sm-pull-3 {
right: 25%;
}
.col-sm-pull-2 {
right: 16.66666667%;
}
.col-sm-pull-1 {
right: 8.33333333%;
}
.col-sm-pull-0 {
right: auto;
}
.col-sm-push-12 {
left: 100%;
}
.col-sm-push-11 {
left: 91.66666667%;
}
.col-sm-push-10 {
left: 83.33333333%;
}
.col-sm-push-9 {
left: 75%;
}
.col-sm-push-8 {
left: 66.66666667%;
}
.col-sm-push-7 {
left: 58.33333333%;
}
.col-sm-push-6 {
left: 50%;
}
.col-sm-push-5 {
left: 41.66666667%;
}
.col-sm-push-4 {
left: 33.33333333%;
}
.col-sm-push-3 {
left: 25%;
}
.col-sm-push-2 {
left: 16.66666667%;
}
.col-sm-push-1 {
left: 8.33333333%;
}
.col-sm-push-0 {
left: auto;
}
.col-sm-offset-12 {
margin-left: 100%;
}
.col-sm-offset-11 {
margin-left: 91.66666667%;
}
.col-sm-offset-10 {
margin-left: 83.33333333%;
}
.col-sm-offset-9 {
margin-left: 75%;
}
.col-sm-offset-8 {
margin-left: 66.66666667%;
}
.col-sm-offset-7 {
margin-left: 58.33333333%;
}
.col-sm-offset-6 {
margin-left: 50%;
}
.col-sm-offset-5 {
margin-left: 41.66666667%;
}
.col-sm-offset-4 {
margin-left: 33.33333333%;
}
.col-sm-offset-3 {
margin-left: 25%;
}
.col-sm-offset-2 {
margin-left: 16.66666667%;
}
.col-sm-offset-1 {
margin-left: 8.33333333%;
}
.col-sm-offset-0 {
margin-left: 0%;
}
.visible-xs {
display: none !important;
}
.hidden-xs {
display: block !important;
}
table.hidden-xs {
display: table;
}
tr.hidden-xs {
display: table-row !important;
}
th.hidden-xs,
td.hidden-xs {
display: table-cell !important;
}
.hidden-xs.hidden-print {
display: none !important;
}
.hidden-sm {
display: none !important;
}
.visible-sm {
display: block !important;
}
table.visible-sm {
display: table;
}
tr.visible-sm {
display: table-row !important;
}
th.visible-sm,
td.visible-sm {
display: table-cell !important;
}
}
Copyright (C) 2016 Donnie Ray Jones
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@unifisa
Copy link

unifisa commented May 20, 2016

Great!!!!!!!!

@ramlotte
Copy link

ramlotte commented May 24, 2016

Everyone who uses this should buy you a beer, including me. Thank you!!!!!

@tysonbird
Copy link

tysonbird commented Jul 1, 2016

Awesome work! Thank you

@larsnextware
Copy link

larsnextware commented Aug 14, 2016

Nice, work perfectly!

@mpalomino
Copy link

mpalomino commented Aug 31, 2016

THANKS A-LOT!

@squalltua
Copy link

squalltua commented Sep 30, 2016

👍 :shipit:

@sheiksalahudeen
Copy link

sheiksalahudeen commented Oct 24, 2016

Thank a lot. Its pretty Cool.

@anothergituser
Copy link

anothergituser commented Feb 9, 2017

still working in 2017!! thanks

@vrdriver
Copy link

vrdriver commented Mar 18, 2017

YESSSS!!!!! Awesome! Use this for this template: https://github.com/puikinsh/gentelella
It's been driving me crazy. Thanks!
I've also added the following in my CSS, otherwise the links of FA get appended to the icon in full text. Highly painful - like so many things in Bootstrap. It's a love hate relationship.

@media print {
a[href]:after {
content: none !important;
}
body {-webkit-print-color-adjust: exact !important;}
}

@kasra-appscore
Copy link

kasra-appscore commented Jun 15, 2017

It doesn't work for me :(

@jjaegerjaquez
Copy link

jjaegerjaquez commented Jul 14, 2017

Anyone how do I use this?

@james-poulose
Copy link

james-poulose commented Aug 2, 2017

@jjaegerjaquez Declare the CSS classes on top of your page inside the style block. If it works, i would suggest you to use a LESS file or a dedicated CSS file.

@hookedupjoe
Copy link

hookedupjoe commented Aug 8, 2017

Nice - first hit on the search. Copy / Paste - Done. Sweeeeet! Thank You Very Much!

@abembecker
Copy link

abembecker commented Sep 21, 2017

Saved me a ton of work - thank you!!!

@Untherxadyus
Copy link

Untherxadyus commented Nov 23, 2017

Excellent, in my case I changed it to render in MD instead of SM.

@bl4ck4ndbr0wn
Copy link

bl4ck4ndbr0wn commented Dec 13, 2017

Perfect. Works great on my Certificates in print preview mode and A4 paper.

@nassif7
Copy link

nassif7 commented Jun 1, 2018

awesome
thanks a lot

@diegocam
Copy link

diegocam commented Jun 13, 2018

Bootstrap 4.1.1 is out and this is STILL an issue 😞 . I tried changing what they recommend:
https://getbootstrap.com/docs/4.1/getting-started/browsers-devices/#printing

@media print {
  @page {
    size: auto;
  }
}

and even overwriting their variable$print-page-size in _variables.scss to:

$print-page-size: auto;

but only your solution seems to work. Thank you 👍

@prasath2k4
Copy link

prasath2k4 commented Jul 9, 2018

Thank you so much for this!

@jofftiquez
Copy link

jofftiquez commented Aug 26, 2018

@diegocam damn thanks! bootstrap 4 was the problem after all!

@aoiotoko
Copy link

aoiotoko commented Oct 31, 2018

Thank you!!!

@csorgod
Copy link

csorgod commented Apr 19, 2019

I just change the 'sm' to 'lg' in my VSCode and i can print desktop versions of my website now! Thanks a lot!

@aneessiddique
Copy link

aneessiddique commented Aug 2, 2019

Thanks a lot buddy

@tuanphandeveloper
Copy link

tuanphandeveloper commented Aug 7, 2019

Cheers! great work!

@moohozol
Copy link

moohozol commented Sep 24, 2019

I came out of depression :) Thank you

@jpatel657
Copy link

jpatel657 commented Oct 10, 2019

Its working fine for me...
Nice Job.

@TomBerkGH
Copy link

TomBerkGH commented Dec 10, 2019

This is working fine for me. Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment