Skip to content

Add scroll-margin-top to anchors to accommodate for sticky header #3936

@jakub-g

Description

@jakub-g

When you arrive at a link with anchor, like:
https://yarnpkg.com/advanced/lexicon#transitive-dependency
the browser scrolls the page to the anchor automatically, but it's overlapped by the sticky header, so the user needs to manually scroll.

A solution to this is a CSS like below (checked with devtools, works well)

[id] { scroll-margin-top: 100px; }

(the sticky header has 40+60px computed height).

I don't know where to put this rule though in the codebase. And maybe instead of 100px hardcoded it should use sass calc.

Maybe somewhere here?
https://github.com/yarnpkg/website/blob/master/_sass/_navbar.scss#L2-L3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions