Transparent to Black Nav

by Sebastian Kay

HTML

<div id="nav">
  <div id="logo">Logo</div>
</div>

<div id="hero"></div>

<p>
Some dumby text goes here.
</p>

CSS

body {
  min-height:1200px;
  padding:0px;
  margin:0px;
}
#nav {
  height: 70px;
  background: rgba(55,55,55,0.4);
  display: block;
  position: fixed;
  width: 100%;
  z-index: 99999;
  transition: all ease .5s;
}

#logo {
  color: #fff;
  padding: 20px;
  font-size: 18px;
  transition: all ease .5s;
}

#hero {
  height: 500px;
  width: 100%;
  background: url('http://community.lovenature.com/wp-content/uploads/sites/4/2016/08/jimi-hendrix.jpg');
  background-size: cover;
  background-position: center;
  position: relative;
}

#nav.shrink {
  animation: hide 3s forwards ease-out;
  height: 40px;
  transition: all ease .5s;
  background: black;
  
}

.show {
  animation: show 2.5s forwards ease-out;
}

#nav.shrink #logo {
  padding: 10px;
  transition: all ease .5s;
}

@keyframes hide{
  0% { transform: translateY(0vw);}
  25% { transform: translateY(-5px);}
  50% { transform: translateY(-180px);}
  75% { transform: translateY(-5px);}
  100% { transform: translateY(0vw);}
}

@keyframes show {
  0% { transform: translateY(-80vw);}
  80% { transform: translateY(-5px);}
  100% { transform: translateY(0vw);}
}

JavaScript

$(document).ready(function() {
	$(window).scroll(function() {
  	if($(document).scrollTop() > 80) {
    	$('#nav').addClass('shrink');
    }
    else {
    /*$('#nav').removeClass('shrink');*/
    $("#nav")
    	.removeClass('shrink')
      .addClass($(this).addClass('show'));
    }
  });
});