How do I make a menu like on this website? www.awwwards.com
When scrolling the page with the mouse, the menu will stay at the top and its color will change too. The menu before scroll and after scroll has a different color.
I found a tutorial on the internet but it just had the same color when page is scrolled. Could someone tell me how to change the color?
.menutext {
float: left;
border-bottom:1px solid #d2d6d5;
width: 100%;
background:gray; }
.menutext ul {
margin: 0 0 0 10%; }
.menutext ul li {
float: left;
position: relative;
border-left: none;
list-style: none;
}
.menutext li a {
text-decoration: none;
color: #444;
display: inline-block;
font-size: 14px;
font-family: MuseoSans, serif;
text-transform: uppercase;
padding:10px;
border-right: 1px solid #d2d6d5;
text-align: center;
}
.menutext ul li :hover {
color:#919191;
background-color: #f4f4f4;
}
js
$(document).ready(function() {
// Menentukan elemen yang dijadikan normal yaitu .normal
var normalNavTop = $('.menutext').offset().top;
var normalNav = function(){
var scrollTop = $(window).scrollTop();
// Kondisi jika discroll maka .nav ditambahkan class normal dan sebaliknya
if (scrollTop > normalNavTop) {
$('.menutext').css({ 'position': 'fixed', 'top':0, 'left':0, 'z-index':9999 });
} else {
$('.menutext').css({ 'position': 'relative' });
}
};
// Jalankan fungsi
normalNav();
$(window).scroll(function() {
normalNav();
});
});
html
<div id="menu">
<div class="menutext">
<ul>
<li><a href="#">home</a>
</li>
<li><a href="#">about</a>
</li>
<li><a href="#">product</a>
</li>
</ul>
</div>