Skip to content

Instantly share code, notes, and snippets.

@weeebdev
Created May 28, 2020 07:04
Show Gist options
  • Save weeebdev/3bfa6c59948e0a363cafab0f11bfdac8 to your computer and use it in GitHub Desktop.
Save weeebdev/3bfa6c59948e0a363cafab0f11bfdac8 to your computer and use it in GitHub Desktop.
WHen the user scroll down 50 px
// 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