Hi w3schools,
thanks for your amazing website. I tried to mix two of your "how to" scripts (Hide Menu on Scroll and Shrink Navigation Menu on Scroll) so that my navbar hide after 180px from top.
But… I'm not a coder, I try to learn and it doesn't work for the moment:
<script>
var prevScrollpos = window.pageYOffset;
window.onscroll = function() {
var currentScrollPos = window.pageYOffset;
if (document.body.scrollTop < 180 || document.documentElement.scrollTop < 180 || prevScrollpos > currentScrollPos) {
document.getElementById("navbar").style.top = "0";
} else {
document.getElementById("navbar").style.top = "-180px";
}
prevScrollpos = currentScrollPos;
}
</script>
Any ideas?
Thanks a lot,
Best,
Michael
best regards,
Michael
Website: https://www.schema-studio.ch/