When using position: sticky
inside an absolutely positioned and scrollable container, you might notice the sticky behavior not working in Safari (iOS and desktop). This is due to a known limitation in WebKit, Safari’s rendering engine.
Safari does not properly support position: sticky
inside containers that have:
(a) position: absolute
and (b) overflow: scroll
or overflow: auto
.
In these conditions, sticky elements either don't stick at all or behave unpredictably.
This is caused by how WebKit calculates the sticky offset relative to the wrong scroll container or fails to compute it entirely.
Other modern browsers (Chrome, Firefox, Edge) handle this case more gracefully because of better implementation of the CSS sticky positioning spec.
If your structure resembles the following:
A parent element with position: absolute
and overflow: scroll
Inside it, a child element with position: sticky
Then Safari will ignore the sticky behavior.
Even if this works in Chrome or Firefox, it will fail in Safari due to the layout computation issue in its rendering engine.
To fix or bypass the issue, try one of the following solutions:
Change the parent to position: relative
instead of absolute
:
This often resolves the bug since Safari handles position: sticky
better within relatively positioned containers.
Example: Replace position: absolute
with position: relative
on the scrollable parent if layout permits.
Move the sticky element outside of scrolling container:
If your layout allows, place the sticky element in a higher-level container that is not affected by overflow.
Use JavaScript as a fallback:
For critical sticky behavior, use JavaScript to manually update the sticky element’s position on scroll (as a last resort).
This increases complexity and is not recommended unless essential.
Avoid combining absolute positioning, overflow, and sticky within the same hierarchy if Safari support is important.
sticky
elements inside scrollable sections that use absolute
positioning.relative
positioning to containers with sticky children where possible.The position: sticky
property doesn't work in Safari when nested inside an absolutely positioned, scrollable element due to a known WebKit bug. The best solution is to use position: relative
on the scrollable parent or restructure your layout to move the sticky element outside the scroll context.