Skip to content

Commit 1c76325

Browse files
committed
styles: clear the sticky header from every anchor target
Each target carried its own offset, most keyed to a 1200px breakpoint and one to nothing at all, but the header is sticky except under `(width >= 1200px) and (hover: hover)`. None of them matched that, so anchored headings could land under the header instead of below it. Declare the header height and derive one offset from it.
1 parent cdd72f4 commit 1c76325

7 files changed

Lines changed: 12 additions & 27 deletions

File tree

src/components/ui/header/Header.astro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ const navItems = navigationItems.map((item) => {
113113
align-items: center;
114114
gap: var(--space-sm);
115115
padding: var(--space-md);
116+
box-sizing: border-box;
117+
min-block-size: var(--header-height);
116118
}
117119

118120
.brand {

src/components/ui/layout/PageSection.astro

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const ariaLabelledBy = ariaLabel ? undefined : anchorId;
6262
font-size: var(--font-size-2xl);
6363
color: var(--heading-color);
6464
margin: 0;
65-
scroll-margin-top: 6.5rem;
65+
scroll-margin-block-start: var(--anchor-offset);
6666
letter-spacing: -0.01em;
6767
}
6868

@@ -75,10 +75,4 @@ const ariaLabelledBy = ariaLabel ? undefined : anchorId;
7575
margin-inline: auto;
7676
}
7777
}
78-
79-
@media screen and (width >= 1200px) {
80-
.title {
81-
scroll-margin-top: var(--space-2xl);
82-
}
83-
}
8478
</style>

src/pages/downloads/community.astro

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ const setBuiltinId = (wallet: Wallet) => {
231231

232232
<style>
233233
:global(#built-in-exchange) {
234-
scroll-margin-top: var(--space-4xl);
234+
scroll-margin-block-start: var(--anchor-offset);
235235
}
236236

237237
.subheading {
@@ -244,10 +244,4 @@ const setBuiltinId = (wallet: Wallet) => {
244244
.compact-grid {
245245
padding: var(--space-xs) 0 var(--space-md) 0;
246246
}
247-
248-
@media (width <= 1200px) {
249-
:global(#built-in-exchange) {
250-
scroll-margin-top: 6.5rem;
251-
}
252-
}
253247
</style>

src/pages/downloads/index.astro

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,6 @@ const tabs = [
121121

122122
#gui,
123123
#cli {
124-
scroll-margin-top: 6.5rem;
125-
}
126-
127-
@media (width >= 1200px) {
128-
#gui,
129-
#cli {
130-
scroll-margin-top: unset;
131-
}
124+
scroll-margin-block-start: var(--anchor-offset);
132125
}
133126
</style>

src/pages/index.astro

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,10 @@ const { t, localizeHref } = Astro.locals;
176176
min-height: var(--hero-min-height);
177177
}
178178

179-
@media (width <= 1200px) {
180-
#start-using-monero {
181-
scroll-margin-top: 4rem;
182-
}
179+
#about-monero,
180+
#start-using-monero,
181+
#get-involved {
182+
scroll-margin-block-start: var(--anchor-offset);
183183
}
184184

185185
@media (width <= 600px) {

src/pages/resources/moneropedia/index.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ for (const letter of sortedLetters) {
9191

9292
<style>
9393
html {
94-
scroll-padding-top: 4em;
94+
scroll-padding-block-start: var(--anchor-offset);
9595
scroll-behavior: smooth;
9696
}
9797

src/styles/global.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858

5959
/* Layout Spacing */
6060
--page-top-margin: var(--space-2xl);
61+
--header-height: 4.5rem;
62+
--anchor-offset: calc(var(--header-height) + var(--space-xs));
6163
--desktop-padding-inline: 5rem;
6264
--mobile-padding-inline: var(--space-2xl);
6365

0 commit comments

Comments
 (0)