Skip to content

Commit 20765b5

Browse files
authored
Print tweaks (twbs#25164)
* Add min-width to body when printing This should address some inconsistencies between browsers when printing. It applies a min-width to the body so that the content better resembles what your might see on your screen. I've made it a variable for easy customizing, too. * Don't underline buttons when printing * Add basic print styles for page and body size to create a semi-consistent print experience across browsers
1 parent 8184c64 commit 20765b5

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

scss/_print.scss

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
box-shadow: none !important;
2121
}
2222

23-
a,
24-
a:visited {
25-
text-decoration: underline;
23+
a {
24+
&:not(.btn) {
25+
text-decoration: underline;
26+
}
2627
}
2728

2829
// Bootstrap specific; comment the following selector out
@@ -82,6 +83,19 @@
8283

8384
// Bootstrap specific changes start
8485

86+
// Specify a size and min-width to make printing closer across browsers.
87+
// We don't set margin here because it breaks `size` in Chrome. We also
88+
// don't use `!important` on `size` as it breaks in Chrome.
89+
@page {
90+
size: $print-page-size;
91+
}
92+
body {
93+
min-width: $print-body-min-width !important;
94+
}
95+
.container {
96+
min-width: $print-body-min-width !important;
97+
}
98+
8599
// Bootstrap components
86100
.navbar {
87101
display: none;

scss/_variables.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,3 +882,8 @@ $kbd-bg: $gray-900 !default;
882882

883883
$pre-color: $gray-900 !default;
884884
$pre-scrollable-max-height: 340px !default;
885+
886+
887+
// Printing
888+
$print-page-size: a3 !default;
889+
$print-body-min-width: map-get($grid-breakpoints, "lg") !default;

0 commit comments

Comments
 (0)