I set my navbar up with some java script to tell it to add the class .top-of-page when scrolled all the way up in the browser, and that class has a transparent background on the navbar. As soon as I start scrolling down, a background color appears on the navbar. What I am trying to achieve is to have a transition of .3 seconds or so that fades the background on the navbar in and out. Tried a couple different things but couldn't figure this one out, I'm not familiar with java script very much at all.
<script> $(window).on("scroll", function() {
var scrollPos = $(window).scrollTop();
if (scrollPos <= 0) {
$('.navbar-default').addClass('top-of-page');
} else {
$('.navbar-default').removeClass('top-of-page');
}
});
</script>
.navbar-default {
background:linear-gradient(#595959, black);
min-height: 80px;
position: fixed;
border-radius: 5px;
border: none;
width: 100%;
z-index: 1;
}
.top-of-page {
background: transparent;
transition: all 0.3s ease-in-out 0s;
}