Skip to content

Commit f7e12da

Browse files
committed
fix: add body padding-block and edge-margin trimming for vertical breathing room
- Add padding-block: var(--nc-spacing) to body for top/bottom page spacing - Strip margin from first/last visible body children to prevent doubling - Use :nth-last-child(1 of :not(script, style)) to skip trailing <script> tags - Place edge-trimming rules inside @scope so they beat scoped typography margins
1 parent 3d73934 commit f7e12da

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/_document.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
var(#{$prefix}content-shadow-gap)
3333
1fr;
3434
min-height: 100dvh;
35+
padding-block: var(#{$prefix}spacing);
3536
position: relative;
3637
}
3738

src/_grid-columns.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
min-width: 0; // Allow grid children to shrink below intrinsic content width
1616
}
1717

18+
1819
// Fix for frameworks (SvelteKit, etc.) that insert a
1920
// <div style="display: contents"> wrapper between <body> and content.
2021
// display: contents removes the element from the box tree for layout,

src/_typography.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,19 @@ $_heading-phone: (
6262
margin-bottom: var(#{$prefix}spacing);
6363
}
6464

65+
// Prevent double spacing at page edges: body has padding-block,
66+
// so strip margins that would stack with it.
67+
// Must live inside @scope so it beats the scoped margin rules above.
68+
// Uses :nth-child/:nth-last-child(of ...) to skip <script>/<style>.
69+
body > :first-child,
70+
body > :first-child > :first-child {
71+
margin-top: 0;
72+
}
73+
body > :nth-last-child(1 of :not(script, style)),
74+
body > :nth-last-child(1 of :not(script, style)) > :last-child {
75+
margin-bottom: 0;
76+
}
77+
6578

6679

6780
// ----- Lists -----

0 commit comments

Comments
 (0)