Navigation

In this example below you will see how to do a Navigation 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>Navigation </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="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"> 
    <div class="nav">Portfolio</div>
    <div class="block1"></div>
    <div class="block2"></div>
    <div class="block3"></div>
    <div class="block4"></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/navigation-rdjeGx */
body {
  font-family: "IBM Plex Mono", monospace;
  height: 100vh;
  width: 100vw;
  padding: 0;
  margin: 0;
}
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 {
  position: absolute;
  height: 100vh;
  width: 100vw;
  z-index: 10;
  top: 0;
  left: 0;
  text-transform: uppercase;
}
body .portfolio .nav {
  left: 50%;
  top: 15px;
  transform: translatex(-50%);
  position: absolute;
  width: 100px;
  text-align: center;
  border-bottom: 0px solid black;
  transition: all 100ms ease-in-out;
}
body .portfolio .nav:hover {
  border-bottom: 2px solid black;
  cursor: pointer;
}
body .portfolio .block1,
body .portfolio .block2,
body .portfolio .block3,
body .portfolio .block4 {
  text-align: center;
  position: absolute;
  left: 50%;
  transform: translatex(-50%) scale(1, 0);
  height: 100%;
  width: 100%;
  transition: all 200ms ease-in-out;
  transform-origin: top left;
  font-size: 30px;
  color: white;
}
body .portfolio .block1:hover,
body .portfolio .block2:hover,
body .portfolio .block3:hover,
body .portfolio .block4:hover {
  cursor: pointer;
  filter: grayscale(70%);
}
body .portfolio .block1 {
  background: #716df9;
}
body .portfolio .block1:after {
  content: "motion";
  position: relative;
  top: 45%;
}
body .portfolio .block2 {
  background: #4931a8;
}
body .portfolio .block2:after {
  content: "code";
  position: relative;
  top: 45%;
}
body .portfolio .block3 {
  background: #75e2e4;
}
body .portfolio .block3:after {
  content: "contact";
  position: relative;
  top: 45%;
}
body .portfolio .block4 {
  background: #48cdd2;
}
body .portfolio .block4:after {
  content: "design";
  position: relative;
  top: 45%;
}

.first {
  transform: translatex(-50%) scale(1, 1) !important;
}

.second {
  transform: translatex(-50%) scale(0.5, 1) !important;
}

.thrid {
  transform: translatex(-50%) scale(0.5, 0.5) !important;
}

.fourth {
  transform: translatex(-50%) scale(0.5, 0.5) !important;
  transform-origin: top right !important;
}


/*Downloaded from https://www.codeseek.co/michaelrappaz/navigation-rdjeGx */
$(".nav").click(function() {
	$(".block1").addClass("first");
	$(".block2").addClass("first");
	$(".block3").addClass("first");
	$(".block4").addClass("first");
	setTimeout(function(){
		$(".block4").css("left", "75%");
		$(".block4").css("width", "50%");
		$(".block3").css("width", "50%");
		$(".block3").css("left", "25%");
	}, 400);
	setTimeout(function(){
		$(".block3").css("height", "50%");
		$(".block4").css("height", "50%");
		$(".block4").css("width", "50%");
		$(".block3").css("width", "50%");
		$(".block1").css("width", "50%");
		$(".block1").css("left", "25%");
	}, 800);
	setTimeout(function(){
		$(".block1").css("top", "50%");
		$(".block2").css("top", "50%");
		$(".block1").css("height", "50%");
		$(".block2").css("height", "50%");
		$(".block2").css("left", "75%");
		$(".block2").css("width", "50%");
	}, 1200);
});

Comments