Skip to content

Instantly share code, notes, and snippets.

@michaelbonner
Last active June 5, 2024 17:18
Show Gist options
  • Save michaelbonner/201c932c5505216d08a40ccdf1266815 to your computer and use it in GitHub Desktop.
Save michaelbonner/201c932c5505216d08a40ccdf1266815 to your computer and use it in GitHub Desktop.
Why isn't position sticky working
// Postition sticky won't work if any of that elements ancestors have overflow hidden, auto, or scroll
let parent = document.querySelector('.sticky').parentElement;
while (parent) {
const hasOverflow = getComputedStyle(parent).overflow;
if (hasOverflow !== 'visible') {
console.log(hasOverflow, parent);
}
parent = parent.parentElement;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment