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

This comment has been minimized.

Copy link

@mvberg mvberg commented Jun 4, 2015

100%

@chillyspoon

This comment has been minimized.

Copy link

@chillyspoon chillyspoon commented Jun 27, 2015

Excellent

@kiran143

This comment has been minimized.

Copy link

@kiran143 kiran143 commented Jul 14, 2015

Excellent work ๐Ÿ˜„

@dan-rigby32

This comment has been minimized.

Copy link

@dan-rigby32 dan-rigby32 commented Aug 30, 2015

Thanks!

@chadokruse

This comment has been minimized.

Copy link

@chadokruse chadokruse commented Dec 31, 2015

๐Ÿ‘

@AndersBillLinden

This comment has been minimized.

Copy link

@AndersBillLinden AndersBillLinden commented Jan 12, 2016

๐Ÿ‘

@rgmullis

This comment has been minimized.

Copy link

@rgmullis rgmullis commented Jan 20, 2016

You are AWESOME! Thanks so much!

@joevago

This comment has been minimized.

Copy link

@joevago joevago commented Feb 3, 2016

Thank you very much!

@kendagriff

This comment has been minimized.

Copy link

@kendagriff kendagriff commented Feb 12, 2016

๐Ÿ‘ Fantastic!

@vkill

This comment has been minimized.

Copy link

@vkill vkill commented Feb 29, 2016

๐Ÿ‘

@cymr0

This comment has been minimized.

Copy link

@cymr0 cymr0 commented Mar 1, 2016

๐Ÿ‘

@MuTLY

This comment has been minimized.

Copy link

@MuTLY 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.

Copy link

@kevindecapite kevindecapite commented Apr 2, 2016

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.

Copy link

@unifisa unifisa commented May 20, 2016

Great!!!!!!!!

@ramlotte

This comment has been minimized.

Copy link

@ramlotte ramlotte commented May 24, 2016

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

@tysonbird

This comment has been minimized.

Copy link

@tysonbird tysonbird commented Jul 1, 2016

Awesome work! Thank you

@larsnextware

This comment has been minimized.

Copy link

@larsnextware larsnextware commented Aug 14, 2016

Nice, work perfectly!

@mpalomino

This comment has been minimized.

Copy link

@mpalomino mpalomino commented Aug 31, 2016

THANKS A-LOT!

@squalltua

This comment has been minimized.

Copy link

@squalltua squalltua commented Sep 30, 2016

๐Ÿ‘ :shipit:

@sheiksalahudeen

This comment has been minimized.

Copy link

@sheiksalahudeen sheiksalahudeen commented Oct 24, 2016

Thank a lot. Its pretty Cool.

@anothergituser

This comment has been minimized.

Copy link

@anothergituser anothergituser commented Feb 9, 2017

still working in 2017!! thanks

@vrdriver

This comment has been minimized.

Copy link

@vrdriver 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

This comment has been minimized.

Copy link

@kasra-appscore kasra-appscore commented Jun 15, 2017

It doesn't work for me :(

@jjaegerjaquez

This comment has been minimized.

Copy link

@jjaegerjaquez jjaegerjaquez commented Jul 14, 2017

Anyone how do I use this?

@james-poulose

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

@hookedupjoe hookedupjoe commented Aug 8, 2017

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

@abembecker

This comment has been minimized.

Copy link

@abembecker abembecker commented Sep 21, 2017

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

@Untherxadyus

This comment has been minimized.

Copy link

@Untherxadyus Untherxadyus commented Nov 23, 2017

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

@bl4ck4ndbr0wn

This comment has been minimized.

Copy link

@bl4ck4ndbr0wn bl4ck4ndbr0wn commented Dec 13, 2017

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

@nassif7

This comment has been minimized.

Copy link

@nassif7 nassif7 commented Jun 1, 2018

awesome
thanks a lot

@diegocam

This comment has been minimized.

Copy link

@diegocam 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

This comment has been minimized.

Copy link

@prasath2k4 prasath2k4 commented Jul 9, 2018

Thank you so much for this!

@jofftiquez

This comment has been minimized.

Copy link

@jofftiquez jofftiquez commented Aug 26, 2018

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

@aoiotoko

This comment has been minimized.

Copy link

@aoiotoko aoiotoko commented Oct 31, 2018

Thank you!!!

@csorgod

This comment has been minimized.

Copy link

@csorgod 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

This comment has been minimized.

Copy link

@aneessiddique aneessiddique commented Aug 2, 2019

Thanks a lot buddy

@tuanphandeveloper

This comment has been minimized.

Copy link

@tuanphandeveloper tuanphandeveloper commented Aug 7, 2019

Cheers! great work!

@moohozol

This comment has been minimized.

Copy link

@moohozol moohozol commented Sep 24, 2019

I came out of depression :) Thank you

@jpatel657

This comment has been minimized.

Copy link

@jpatel657 jpatel657 commented Oct 10, 2019

Its working fine for me...
Nice Job.

@TomBerkGH

This comment has been minimized.

Copy link

@TomBerkGH 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
You canโ€™t perform that action at this time.