-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a navbar component which is made responsive using DOM manipulation.
- Loading branch information
1 parent
2e6cc16
commit 36b3d31
Showing
6 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}) |