How to create responsive navigation bar using HTML and CSS

Hello friends, today we will be going to how do we Create Responsive Navigation Bar using HTML and CSS. I have posted many videos and articles before related to the JavaScript project, now this the something new that we are going to build.

Video Tutorial of How to Create Responsive Navigation Bar using HTML and CSS


As you have seen on the given video tutorial of  How to Create Responsive Navigation Bar using HTML and CSS, 

If you are feeling bored watching the given video tutorial of How to Create Responsive Navigation Bar using HTML and CSS then you can copy or download the given codes below:


How to Create Responsive Navigation Bar using HTML and CSS | Free Source Code

To create this program (Responsive Navigation Bar). First, you need to create two Files one HTML File and another one is CSS File. After creating these files just paste the following codes in your file.

In the first place, make a HTML document with the name of index.html and glue the given codes in your HTML record. Keep in mind, you've to make a document with .html extension.
<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <link rel="stylesheet" href="style.css">
   <title>Responsive Animated Navigation Bar Design using Html CSS & JS</title>

   <!-- Created by S-Tech04 -->

</head>
<body>
   <header>
      <a href="#" class="logo">Logo</a>
      <div class="toggle" onclick="menuToggle()"></div>
      <ul class="navigation">
         <li><a href="#" style="--i:1">Home</a></li>
         <li><a href="#" style="--i:2">About</a></li>
         <li><a href="#" style="--i:3">Portfolio</a></li>
         <li><a href="#" style="--i:4">Contact</a></li>
         <li><a href="#" style="--i:5">More</a></li>
      </ul>
   </header>
   <script>
      function menuToggle(){
         const toggle = document.querySelector('.toggle');
         const navigation = document.querySelector('.navigation');
         toggle.classList.toggle('active');
         navigation.classList.toggle('active');
      }
   </script>
</body>
</html>
Second, make a CSS record with the name of style.css and glue the given codes in your CSS document. Keep in mind, you've to make a record with .css extension.
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@100;200;300;400;500;700;900&display=swap');
*
{
   margin: 0;
   padding: 0;
   box-sizing: border-box;
   font-family: 'Poppins', sans-serif;
}
body
{
   height: 100vh;
   background: url(./images/bg.jpg);
   background-position: center;
   background-size: cover;
   background-repeat: no-repeat;
   overflow-x: hidden;
}
header
{
   position: fixed;
   top: 0;
   left: 0;
   width: 100%;
   padding: 40px 100px;
   display: flex;
   justify-content: space-between;
   align-items: center;
   z-index: 1000;
}
.logo
{
   position: relative;
   font-size: 28px;
   color: #111;
   font-weight: 700;
   text-decoration: none;
   text-transform: uppercase;
   letter-spacing: 2px;
   animation: slideLeft 0.5s linear forwards;
   opacity: 0;
}
.toggle
{
   position: relative;
   height: 30px;
   width: 30px;
   background: url(./images/menu.png);
   background-position: center;
   background-repeat: no-repeat;
   background-size: cover;
   cursor: pointer;
   z-index: 1000;
   animation: slideRight 0.5s linear forwards;
   opacity: 0;
}
.toggle.active
{
   background: url(./images/close.png);
   background-position: center;
   background-repeat: no-repeat;
   background-size: 30px;
}
.navigation
{
   position: absolute;
   display: flex;
   right: 150px;
   opacity: 0;
   visibility: hidden;
   transition: 0.5s;
}
.navigation.active
{
   opacity: 1;
   visibility: visible;
}
.navigation li
{
   list-style: none;
}
.navigation li a
{
   display: inline-block;
   text-decoration: none;
   margin: 0px 20px;
   color: #111;
   font-size: 16px;
   font-weight: 600;
   opacity: 0;
}
.navigation.active li a
{
   animation: slideRight 0.5s forwards;
   animation-delay: calc(var(--i) * 0.2s);
}


/* now i'll add animation on this page */

@keyframes slideRight
{
   0%
   {
      transform: translateX(150px);
      opacity: 0;
   }
   100%
   {
      transform: translateX(0px);
      opacity: 1;
   }
}
@keyframes slideLeft
{
   0%
   {
      transform: translateX(-150px);
      opacity: 0;
   }
   100%
   {
      transform: translateX(0px);
      opacity: 1;
   }
}
/* now i'll make it responsive */
@media(max-width: 991px){
   header
   {
      padding: 20px 40px;
      height: 75px;
   }
   .navigation
   {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100vh;
      background: #fff;
      display: flex;
      justify-content: center;
      align-items: center;
      flex-direction: column;
   }
   .navigation.active li a
   {
      display: inline-block;
      margin: 10px 20px;
      font-size: 20px;
      color: #111;
   }
}
That’s all, now you’ve successfully created a program to How to Create Responsive Navigation Bar using HTML and CSS. If your code doesn’t work or you’ve faced any error/problem, please download the source code files from the given download button. It’s free and a .zip file will be downloaded then you’ve to extract it.
Click on the following download button to download all source code files.


Download Now
Please Wait...
Direct Link click here.

How can I help you

Post a Comment

How can I help you

Post a Comment (0)

Previous Post Next Post