Repository navigation
Expand file tree
/
Copy pathUpdates
More file actions
172 lines (140 loc) · 5.96 KB
/
Copy pathUpdates
File metadata and controls
172 lines (140 loc) · 5.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
I can see the exact cause now — the visibility approach combined with the page structure is fighting you. The real culprit is that #field-techniques is a direct child of .container, and both the .container and the section are still taking up their full layout height in print, which creates those trailing blank pages. The heading leakage comes from the h2 and the first h3 inside the section still being visible because my selector logic was over-clever.
Let me give you a completely bulletproof approach that uses a known-tested pattern: instead of trying to hide everything and reveal pieces, we wrap the checklist in its own print-only container and use display: none on everything else. This is the pattern used by every reliable "print this section only" solution.
Step 1 — Add a wrapper around the checklist
In your #field-techniques section, wrap the checklist heading, list, and print button together in a single container. Change this:
```html
<h3 class="checklist-heading">Field Kit Checklist</h3>
<div class="checklist" id="fieldChecklist">
...items...
</div>
<button class="print-btn" onclick="window.print()">
<i class="fas fa-print"></i> Print Checklist
</button>
```
To this:
```html
<div class="print-area" id="checklistArea">
<h3 class="checklist-heading">Field Kit Checklist</h3>
<div class="checklist" id="fieldChecklist">
...items... (unchanged)
</div>
<button class="print-btn" onclick="window.print()">
<i class="fas fa-print"></i> Print Checklist
</button>
</div>
```
Everything inside .print-area stays exactly as it is — just wrapped.
Step 2 — Replace the entire @media print block
Delete everything from /* ---------- PRINT: CHECKLIST ONLY ---------- */ down to the final } of that media block (including the stray brace and the orphaned section { page-break-inside: auto; } rules), and replace it with:
```css
/* ---------- PRINT: CHECKLIST ONLY ---------- */
@media print {
/* Reset page */
html, body {
margin: 0 !important;
padding: 0 !important;
background: #fff !important;
height: auto !important;
}
/* Hide the entire document by default */
body > * {
display: none !important;
}
/* Reveal ONLY the .container and everything up to the checklist area */
body > .container {
display: block !important;
max-width: none !important;
padding: 0 !important;
margin: 0 !important;
}
/* Hide all sections except field-techniques */
.container > section {
display: none !important;
}
.container > #field-techniques {
display: block !important;
padding: 0 !important;
margin: 0 !important;
border: none !important;
box-shadow: none !important;
background: #fff !important;
}
/* Inside field-techniques, hide everything except the checklist area */
#field-techniques > * {
display: none !important;
}
#field-techniques > .print-area {
display: block !important;
}
/* The print area itself */
.print-area {
display: block !important;
}
/* Title printed above the checklist */
.print-area .checklist-heading {
display: block !important;
font-size: 1.4rem !important;
font-weight: 700 !important;
color: #1e3a1e !important;
border-bottom: 3px solid #e6b422 !important;
padding-bottom: 0.4rem !important;
margin-bottom: 0.8rem !important;
}
/* The checklist layout for print */
.print-area .checklist {
display: block !important;
width: 100% !important;
margin: 0 !important;
padding: 0 !important;
grid-template-columns: none !important;
gap: 0 !important;
}
.print-area .checklist-item {
display: flex !important;
align-items: center;
gap: 0.6rem;
padding: 0.4rem 0;
background: none !important;
border-bottom: 1px dotted #bbb;
page-break-inside: avoid;
}
.print-area .checklist-item input[type="checkbox"] {
width: 14px;
height: 14px;
accent-color: #000;
}
.print-area .checklist-item label {
font-size: 0.95rem;
color: #000;
}
/* Hide the print button itself */
.print-area .print-btn {
display: none !important;
}
/* Optional: a small footer under the checklist */
.print-area::after {
content: "CIII CEM · Tasmanian Ecosystem Maintenance";
display: block;
margin-top: 1rem;
font-size: 0.75rem;
color: #888;
text-align: center;
}
}
```
Why this works (and the previous attempts didn't)
The three previous failures each had a different root cause:
1. First version (visibility: hidden) — hidden elements still reserve layout height, so 8 pages of "invisible but present" content got printed as blank pages.
2. *Second version (display: none on body > ) — the sticky .nav-wrapper created a positioned context that forced the page to still be laid out, and the specificity of my nth-of-type heading selector was fragile.
3. Third version — same sticky problem, plus an imbalance of braces was silently breaking the stylesheet parsing.
The new approach is the standard pattern used by print-stylesheet libraries:
· body > * { display: none } removes everything from the layout tree — no reserved space, no blank pages.
· Then we walk back down the specific chain we need: .container → #field-techniques → .print-area → .checklist.
· Every other sibling gets re-hidden explicitly at each level (#field-techniques > * hides all direct children, then .print-area is re-revealed), so nothing leaks through.
· display: none truly removes elements from the render tree, so there is no layout contribution from hidden content — which is what eliminates the trailing blank pages.
Testing checklist
After you make the two changes above:
1. Open the file in your browser
2. Press Ctrl+P (or Cmd+P on Mac)
3. Check the preview — it should be 1 page (maybe 2 if the list is long on your paper size), starting with "Field Kit Checklist — CIII CEM" and ending with the small footer line
4. If your browser shows a different result, tell me which browser and OS — but this pattern is genuinely the most reliable one available