JSFiddle - React, Tailwind, and code Playground
HTML
<div class="menu">
<div id="menu-center">
<ul>
<li><a class="active" href="#home">Home</a>
</li>
<li><a class="inactive" href="#portfolio">Portfolio</a>
</li>
<li><a class="inactive" href="#about">About</a>
</li>
<li><a class="inactive" href="#contact">Contact</a>
</li>
</ul>
</div>
</div>
<div id="home"></div>
<div id="portfolio"></div>
<div id="about"></div>
<div id="contact"></div>
CSS
body, html {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
}
.menu {
width: 100%;
height: 75px;
background-color: rgba(0, 0, 0, 1);
position: fixed;
transition: all 1000ms ease-in;
}
.light-menu {
width: 100%;
height: 75px;
background-color: rgba(255, 255, 255, 1);
position: fixed;
transition: all 1000ms ease-in;
}
#menu-center {
width: 980px;
height: 75px;
margin: 0 auto;
}
#menu-center ul {
margin: 15px 0 0 0;
}
#menu-center ul li {
list-style: none;
margin: 0 30px 0 0;
display: inline;
}
.active {
font-family:'Droid Sans', serif;
font-size: 14px;
color: #fff;
text-decoration: none;
line-height: 50px;
}
.inactive {
font-family:'Droid Sans', serif;
font-size: 14px;
color: #9e9e9e;
text-decoration: none;
line-height: 50px;
}
#home {
background-color: grey;
height: 100%;
width: 100%;
overflow: hidden;
background-image: url(images/home-bg2.png);
}
#portfolio {
background-image: url(images/portfolio-bg.png);
height: 100%;
width: 100%;
}
#about {
background-color: blue;
height: 100%;
width: 100%;
}
#contact {
background-color: red;
height: 100%;
width: 100%;
}
JavaScript
$(document).ready(function () {
var menu = $('.menu');
$(window).scroll(function () {
var y = $(this).scrollTop();
var z = $('#portfolio').offset().top;
if (y >= z) {
menu.removeClass('menu').addClass('light-menu');
}
});
});