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

fix(layout): avoid sticky header gap #11644

Merged
merged 6 commits into from
Dec 6, 2024
Merged

fix(layout): avoid sticky header gap #11644

merged 6 commits into from
Dec 6, 2024

Conversation

OnkarRuikar
Copy link
Contributor

@OnkarRuikar OnkarRuikar commented Aug 17, 2024

Summary

Depending on the zoom level, the sticky-header-container leaves a 1px gap on the top.

Problem

Refer to the following video:

stiky_header_1px_gap.mp4

Note that the viewport's top border has white dots.

Make sure you have the dark theme on. If you can not reproduce it, change the browser zoom level slightly and scroll so that some text reaches the top border of the viewport. Keep changing zoom till you see the gap. I can reproduce this in Firefox and Chrome.

Solution

This is due to some zoom levels producing fractions in the header dimensions, so a 1px gap remains after rounding. Pulling the header 1px up by using top: -1px should cover the gap.


How did you test this change?

In a browser before and after the fix.

@OnkarRuikar OnkarRuikar requested a review from a team as a code owner August 17, 2024 06:32
@github-actions github-actions bot added the idle label Sep 16, 2024
@caugner
Copy link
Contributor

caugner commented Sep 27, 2024

I can reproduce this in Firefox and Chrome.

I was able to reproduce in BrowserStack Live at 1920x970 on Windows 11 with Chrome 128 consistently at zoom level 75% (but not at 67% / 80% / 90%), and with Firefox 130 once at zoom level 67% (but not at other zoom levels).

The header.top-navigation element nevertheless has a clientTop: 0, so I'm wondering if this is a browser bug?

@github-actions github-actions bot removed the idle label Sep 27, 2024
client/src/app.scss Outdated Show resolved Hide resolved
Co-authored-by: Onkar Khadangale <[email protected]>
@caugner caugner changed the title fix(client): sticky header leaves 1px gap on top fix(layout): avoid sticky header gap Nov 12, 2024
@github-actions github-actions bot removed the idle label Nov 12, 2024
@argl argl merged commit ee6c092 into mdn:main Dec 6, 2024
13 checks passed
@OnkarRuikar OnkarRuikar deleted the patch-2 branch December 7, 2024 01:38
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.

3 participants