Navigation2

In this example below you will see how to do a Navigation2 with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by michaelrappaz, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright michaelrappaz ©

Technologies

  • HTML
  • CSS
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>Navigation2</title>
  <link href="https://fonts.googleapis.com/css?family=IBM+Plex+Mono" rel="stylesheet">
  
  
      <link rel="stylesheet" href="css/style.css">

  
</head>

<body>

  
<body>
  <div class="nav">Portfolio</div>
  <div class="main_block">
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero.</p>
  </div>
  <div class="portfolio hidden">
    <div class="block1 hidden">
      <p>Motion</p>
    </div>
    <div class="block2 hidden">
      <p>Coding</p>
    </div>
    <div class="block3 hidden">
      <p>Design</p>
    </div>
    <div class="block4 hidden">
      <p>About me</p>
    </div>
  </div>
</body>
  <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script>

  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/michaelrappaz/navigation2-aYJexx */
body {
  font-family: "IBM Plex Mono", monospace;
  height: 100vh;
  width: 100vw;
  padding: 0;
  margin: 0;
}
body .close {
  z-index: 50;
  font-size: 20px;
  position: absolute;
  right: 0;
  padding: 15px;
}
body .nav {
  left: 50%;
  top: 15px;
  transform: translatex(-50%);
  position: absolute;
  z-index: 10;
  width: 100px;
  text-align: center;
  border-bottom: 0px solid black;
  transition: all 100ms ease-in-out;
}
body .nav:hover {
  border-bottom: 2px solid black;
  cursor: pointer;
}
body .main_block {
  border: 1px solid black;
  text-align: center;
  height: auto;
  width: 400px;
  position: relative;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
body .portfolio {
  transition: all 200ms ease-in-out;
  position: absolute;
  height: 100vh;
  width: 100vw;
  z-index: 10;
  top: 0;
  left: 0;
  text-transform: uppercase;
}
body .portfolio .block1,
body .portfolio .block2,
body .portfolio .block3,
body .portfolio .block4,
body .portfolio .block5 {
  position: absolute;
  height: 50%;
  width: 50%;
  transition: all 200ms ease-in-out;
  transform-origin: top left;
  font-size: 30px;
  color: black;
  background: white;
  border: 1px solid black;
  box-sizing: border-box;
}
body .portfolio .block1:hover,
body .portfolio .block2:hover,
body .portfolio .block3:hover,
body .portfolio .block4:hover,
body .portfolio .block5:hover {
  cursor: pointer;
  filter: grayscale(70%);
}
body .portfolio .block1 p,
body .portfolio .block2 p,
body .portfolio .block3 p,
body .portfolio .block4 p,
body .portfolio .block5 p {
  text-align: center;
  padding: 0;
  margin: 0;
  position: relative;
  top: 50%;
  transform: translatey(-50%);
}
body .portfolio .block1 {
  left: 0;
  top: 0;
  z-index: 50;
  width: 100%;
  height: 0%;
}
body .portfolio .block2 {
  top: 0;
  right: 0;
  z-index: 40;
  height: 100%;
}
body .portfolio .block3 {
  left: 0;
  bottom: 0;
  z-index: 30;
}
body .portfolio .block4 {
  right: 0;
  bottom: 0;
  z-index: 25;
}

.hidden {
  visibility: hidden;
  display: none;
}


/*Downloaded from https://www.codeseek.co/michaelrappaz/navigation2-aYJexx */
$(".nav").click(function() {
	$(".portfolio").removeClass("hidden");
	$(".block1").removeClass("hidden");	
	$(".block1").css("height", "100%");
	setTimeout(function(){
		$(".block2").removeClass("hidden");	
		$(".block3").removeClass("hidden");	
		$(".block4").removeClass("hidden");	
		$(".block1").css("width", "50%");	
	}, 200);
	setTimeout(function(){
		$(".block1").css("height", "50%");
	}, 400);
	setTimeout(function(){
		$(".block2").css("height", "50%");
	}, 600);
	setTimeout(function(){
		$(".block4").css("width", "50%");
		$(".close").removeClass("hidden");	
	}, 800);
});

Comments