Create a gist now

Instantly share code, notes, and snippets.

Embed
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.
@mvberg

This comment has been minimized.

Show comment
Hide comment

mvberg commented Jun 4, 2015

100%

@chillyspoon

This comment has been minimized.

Show comment
Hide comment

Excellent

@kiran143

This comment has been minimized.

Show comment
Hide comment
@kiran143

kiran143 Jul 14, 2015

Excellent work πŸ˜„

Excellent work πŸ˜„

@dan-rigby32

This comment has been minimized.

Show comment
Hide comment

Thanks!

@chadokruse

This comment has been minimized.

Show comment
Hide comment

πŸ‘

@AndersBillLinden

This comment has been minimized.

Show comment
Hide comment

πŸ‘

@rgmullis

This comment has been minimized.

Show comment
Hide comment
@rgmullis

rgmullis Jan 20, 2016

You are AWESOME! Thanks so much!

You are AWESOME! Thanks so much!

@joevago

This comment has been minimized.

Show comment
Hide comment
@joevago

joevago Feb 3, 2016

Thank you very much!

joevago commented Feb 3, 2016

Thank you very much!

@kendagriff

This comment has been minimized.

Show comment
Hide comment
@kendagriff

kendagriff Feb 12, 2016

πŸ‘ Fantastic!

πŸ‘ Fantastic!

@vkill

This comment has been minimized.

Show comment
Hide comment
@vkill

vkill Feb 29, 2016

πŸ‘

vkill commented Feb 29, 2016

πŸ‘

@cymr0

This comment has been minimized.

Show comment
Hide comment
@cymr0

cymr0 Mar 1, 2016

πŸ‘

cymr0 commented Mar 1, 2016

πŸ‘

@MuTLY

This comment has been minimized.

Show comment
Hide comment
@MuTLY

MuTLY Mar 28, 2016

This was created over 2 years ago and works great. I'm baffled that the BS team didn't fix this on the BS3 version. Guess we'll have to wait for BS4. In the meantime, thank you, Sir! Excellent work.

MuTLY commented Mar 28, 2016

This was created over 2 years ago and works great. I'm baffled that the BS team didn't fix this on the BS3 version. Guess we'll have to wait for BS4. In the meantime, thank you, Sir! Excellent work.

@kevindecapite

This comment has been minimized.

Show comment
Hide comment
@kevindecapite

kevindecapite Apr 2, 2016

I feel like an idiot. Can't figure out how to use it :-/ Seems to have no effect whatsoever.

I feel like an idiot. Can't figure out how to use it :-/ Seems to have no effect whatsoever.

@unifisa

This comment has been minimized.

Show comment
Hide comment
@unifisa

unifisa May 20, 2016

Great!!!!!!!!

unifisa commented May 20, 2016

Great!!!!!!!!

@ramlotte

This comment has been minimized.

Show comment
Hide comment
@ramlotte

ramlotte May 24, 2016

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

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

@tysonbird

This comment has been minimized.

Show comment
Hide comment
@tysonbird

tysonbird Jul 1, 2016

Awesome work! Thank you

Awesome work! Thank you

@larsnextware

This comment has been minimized.

Show comment
Hide comment
@larsnextware

larsnextware Aug 14, 2016

Nice, work perfectly!

Nice, work perfectly!

@mpalomino

This comment has been minimized.

Show comment
Hide comment
@mpalomino

mpalomino Aug 31, 2016

THANKS A-LOT!

THANKS A-LOT!

@squalltua

This comment has been minimized.

Show comment
Hide comment

πŸ‘ :shipit:

@sheiksalahudeen

This comment has been minimized.

Show comment
Hide comment
@sheiksalahudeen

sheiksalahudeen Oct 24, 2016

Thank a lot. Its pretty Cool.

Thank a lot. Its pretty Cool.

@anothergituser

This comment has been minimized.

Show comment
Hide comment
@anothergituser

anothergituser Feb 9, 2017

still working in 2017!! thanks

still working in 2017!! thanks

@vrdriver

This comment has been minimized.

Show comment
Hide comment
@vrdriver

vrdriver 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;}
}

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

This comment has been minimized.

Show comment
Hide comment
@kasra-appscore

kasra-appscore Jun 15, 2017

It doesn't work for me :(

It doesn't work for me :(

@jjaegerjaquez

This comment has been minimized.

Show comment
Hide comment
@jjaegerjaquez

jjaegerjaquez Jul 14, 2017

Anyone how do I use this?

Anyone how do I use this?

@james-poulose

This comment has been minimized.

Show comment
Hide comment
@james-poulose

james-poulose 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.

@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

This comment has been minimized.

Show comment
Hide comment
@hookedupjoe

hookedupjoe Aug 8, 2017

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

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

@abembecker

This comment has been minimized.

Show comment
Hide comment
@abembecker

abembecker Sep 21, 2017

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

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

@Untherxadyus

This comment has been minimized.

Show comment
Hide comment
@Untherxadyus

Untherxadyus Nov 23, 2017

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

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

@bl4ck4ndbr0wn

This comment has been minimized.

Show comment
Hide comment
@bl4ck4ndbr0wn

bl4ck4ndbr0wn Dec 13, 2017

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

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

@nassif7

This comment has been minimized.

Show comment
Hide comment
@nassif7

nassif7 Jun 1, 2018

awesome
thanks a lot

nassif7 commented Jun 1, 2018

awesome
thanks a lot

@diegocam

This comment has been minimized.

Show comment
Hide comment
@diegocam

diegocam 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 πŸ‘

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 πŸ‘

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