Skip to content

Commit

Permalink
JS navbar folder added
Browse files Browse the repository at this point in the history
This is a navbar component which is made responsive using DOM manipulation.
  • Loading branch information
amansingh1912 committed Oct 21, 2021
1 parent 2e6cc16 commit 36b3d31
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 0 deletions.
1 change: 1 addition & 0 deletions js navbar/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### This is a navbar component which is made responsive using DOM manipulation.
24 changes: 24 additions & 0 deletions js navbar/css/resp.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@media only screen and (max-width:800px) {
.line {
visibility: visible;
}
.nav-menu {
flex-direction: column;
}
.nav-items {
flex-direction: column;
height: 0px;
transition: all 0.6s ease-in;
/* //-> the transition property will work on the selected query on which we apply toggle in JS, So it is applied on "nav-items" not on "show-items" */
}
.show-items {
height: 210px;
}
.nav-resp {
/* height: 40px; */
}
.navbar {
/* height: 100px; */
}
.nav-menu {}
}
49 changes: 49 additions & 0 deletions js navbar/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
* {
margin: 0px;
padding: 0px;
}

.navbar {
background: rgba(0, 0, 0, 0.7);
}

.nav-menu {
display: flex;
}

.nav-items {
display: flex;
}

.pic img {
height: 40px;
width: 40px;
border: 2px solid grey;
border-radius: 25px;
margin: 5px;
cursor: pointer;
}

.nav-items li {
list-style: none;
margin: 10px 20px;
padding: 4px;
color: white;
font-size: 1.3rem;
cursor: pointer;
}

.burger {
position: absolute;
right: 4px;
top: 10px;
cursor: pointer;
}

.line {
width: 30px;
margin: 4px;
height: 4px;
background: white;
visibility: hidden;
}
37 changes: 37 additions & 0 deletions js navbar/ind.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!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">
<title>Navigation Bar</title>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/resp.css">
</head>

<body>
<nav class="navbar nav-resp">
<div class="nav-menu ">
<div class="pic">
<img src="logo.jpg" alt="logo">
</div>

<ul class="nav-items show-items ">
<li>Home</li>
<li>About</li>
<li>Services</li>
<li>Contact</li>
</ul>
</div>
<div class="burger">
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
</div>
</nav>

<script src="resp.js"></script>
</body>

</html>
Binary file added js navbar/logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions js navbar/resp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
let burger = document.querySelector(".burger");
let navitems = document.querySelector(".nav-items");

burger.addEventListener('click', () => {
navitems.classList.toggle('show-items');
})

0 comments on commit 36b3d31

Please sign in to comment.