Created
May 28, 2020 07:04
-
-
Save weeebdev/3bfa6c59948e0a363cafab0f11bfdac8 to your computer and use it in GitHub Desktop.
WHen the user scroll down 50 px
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
// When the user scrolls down 50px from the top of the document, resize the header's font size | |
window.onscroll = function() {scrollFunction()}; | |
function scrollFunction() { | |
if (document.body.scrollTop > 50 || document.documentElement.scrollTop > 50) { | |
document.getElementById("header").style.fontSize = "30px"; | |
} else { | |
document.getElementById("header").style.fontSize = "90px"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment