Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip link not visible when focused #2138

Closed
glin opened this issue Jun 19, 2022 · 0 comments · Fixed by #2454
Closed

Skip link not visible when focused #2138

glin opened this issue Jun 19, 2022 · 0 comments · Fixed by #2454
Labels
bug an unexpected problem or unintended behavior front end 🌷 General HTML, CSS, and JS issues
Milestone

Comments

@glin
Copy link

glin commented Jun 19, 2022

I'm migrating a doc site to Bootstrap 5 now and am loving all the new features and improvements, thanks for that! There were a couple minor visual/usability issues that I wanted to note from the upgrade.

Issue

The first issue is that the new skip link isn't visible when focused, and also causes the page to shift when focused, so it's a little odd when you navigate to a page and start tabbing.

You can reproduce this by going to any site using Bootstrap 5, like the pkgdown website, and press Tab. Here's what that looks like, with the Chrome inspector showing the skip link hidden behind the navbar:

pkgdown website - skip link focused but not visible

Workaround

To prevent the skip link from being hidden behind the navbar, my workaround is to add CSS to extra.css that absolutely positions it and gives it a higher z-index than the sticky navbar (1030 I think). This is how most sites I've seen with skip links do it:

a[href='#main'] {
  position: absolute;
  z-index: 1040;
}

skip link made visible using the CSS workaround

For my own site, I've also made it more visually prominent, more legible when overlapping navbar text, and added a tiny bit of margin to not clip the focus outline:

a[href='#main'] {
  position: absolute;
  margin: 4px;
  padding: 0.75rem;
  background-color: hsla(0, 0%, 100%, 0.9);
  font-weight: 600;
  text-decoration: none;
  z-index: 1040;
}

skip link made visible using the CSS workaround with additional styling

@hadley hadley added bug an unexpected problem or unintended behavior front end 🌷 General HTML, CSS, and JS issues labels Apr 12, 2024
@hadley hadley added this to the 2.1.0 milestone Apr 12, 2024
hadley added a commit that referenced this issue Apr 16, 2024
With styles inspired by @glin.

Fixes #2138
hadley added a commit that referenced this issue Apr 17, 2024
With styles inspired by @glin.

Fixes #2138
SebKrantz pushed a commit to SebKrantz/pkgdown that referenced this issue Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior front end 🌷 General HTML, CSS, and JS issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants