Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Background color of navbar change on scroll
<div class="nav"></div>
window.onscroll = () => {
const nav = document.querySelector('.nav');
if(this.scrollY <= 500) = 'rgba(0,0,0,0)';
else = 'rgba(0,0,0,0.9)';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.