Last active
June 5, 2024 17:18
-
-
Save michaelbonner/201c932c5505216d08a40ccdf1266815 to your computer and use it in GitHub Desktop.
Why isn't position sticky working
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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