twbs / twbs/bootstrap

Navbar hides initial content when jumping to in-page anchor

Open
#35,900 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

css js v5
Dominant language
MDX
Stars
175k
Forks
78.6k
Avg merge
7h 19m
Merged PRs (30d)
35

Description

Prerequisites
Describe the issue

This issue was already reported and locked at #1768.

Basically, when you jump to an in-page anchor, the target is displayed behind the navbar.

A fix (using scroll-margin-top) was suggested in passing at https://github.com/twbs/bootstrap/pull/30273#issuecomment-598609487

Is it worth adding some docs to the Navbar section, to recommend adding a custom rule like

[id] {
  scroll-margin-top: <your navbar height here>;
}

Or is a more general fix possible ?

Reduced test cases

https://codepen.io/forthadena/pen/oNoMwQd

What operating system(s) are you seeing the problem on?

Windows, macOS, Android, iOS, Linux

What browser(s) are you seeing the problem on?

Chrome, Safari, Firefox

What version of Bootstrap are you using?

5.1.3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked CodePen reduced test case and the Navbar section referenced in the issue. Compare anchor-jump behavior across the listed browsers and determine whether the appropriate outcome is a general fix or documented guidance; done means the target content is no longer obscured, or the Navbar documentation clearly explains the supported workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.