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

[css-overscroll] position: sticky elements should not move during overscroll when in stuck state #8309

Open
atomiks opened this issue Jan 13, 2023 · 1 comment

Comments

@atomiks
Copy link

atomiks commented Jan 13, 2023

Originally made a comment here, but seemed to get lost.

Problem

When combining position: fixed and position: sticky elements together, the latter moves during overscroll despite being in the "stuck" or "fixed" state, causing the issues seen in the demos below. I have noticed this on several sites where elements that should remain together now detach and overlap in undesirable ways when mixing each value.

Demos

Screen.Recording.2023-01-14.at.5.32.46.am.mov
Screen.Recording.2023-01-14.at.5.34.28.am.mov
@jonjohnjohnson
Copy link

jonjohnjohnson commented Feb 24, 2023

Not the cleanest solution, but negative margins can be used to "combat" blocks being unstuck from their constrained box offsets during overscroll in webkit/gecko. You just also need to offset the opposing margin to keep the subsequent flow position intact, as well as keep in mind that this compensating opposite margin will affect where the block becomes "unstuck" when reaching the opposing edge of its containing block.

eg

body {
  background: #f99;
  margin: 0;
}
nav {
  height: 10vh;
  background: #9ff;
  position: sticky;
  top: 0;
  margin-top: -100vh;
  margin-bottom: 100vh;
}
main {
  height: 200vh;
  background: #99f;
  border-top: 5vh solid #999;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants