Skip to content

Clear the navbar when jumping to a subsection on wide screens - #22

Merged
aharvard merged 1 commit into
mainfrom
claude/anchor-link-scroll-offset-442e04
Oct 19, 2026
Merged

aharvard merged 1 commit into
mainfrom
claude/anchor-link-scroll-offset-442e04

Conversation

@aharvard

Copy link
Copy Markdown
Collaborator

On a wide screen, a link to a subsection (h3–h6, like #profile on the working draft) scrolled the heading under the navbar.

Why. The site turns on the theme's navbar.hideOnScroll. With it on, the theme gives every anchor only 0.5rem of scroll-margin-top, because it expects the navbar to slide away. On the wide layout we override that and keep the navbar in place (transform: none above 996px), so the heading lands beneath it. h2s were already fine because they have their own rule that puts their top rule on the navbar's hairline.

Change. Above 996px, anchors other than h2 get the sticky-navbar margin, --ifm-navbar-height + 0.5rem. The selector carries :not(h2) for two reasons: it leaves the h2 rule alone, and it beats the theme's rule, which has the same specificity and loads after custom.css.

Checked in docusaurus start:

  • At 1700px wide, #profile (h3) and #payload-contract (h4) land 9px below the navbar instead of under it.
  • #concepts (h2) still lines up with the hairline.
  • At phone width, anchors keep the theme's 0.5rem, since the navbar hides there.

🤖 Generated with Claude Code

The theme's hideOnScroll gives anchors only 0.5rem of scroll margin,
expecting the navbar to slide away. On the wide layout we keep the navbar
in place, so h3–h6 targets landed beneath it. Give them the sticky-navbar
margin there; h2s keep their own rule that aligns with the hairline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aharvard
aharvard requested a review from daveh-beep as a code owner October 19, 2026 19:03
@aharvard
aharvard merged commit 4abd079 into main Oct 19, 2026
4 checks passed
@aharvard
aharvard deleted the claude/anchor-link-scroll-offset-442e04 branch October 19, 2026 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant