Skip to content

Commit 7e6eaba

Browse files
authored
sidebar menu with html css and javascript
1 parent 0a19608 commit 7e6eaba

File tree

3 files changed

+117
-0
lines changed

3 files changed

+117
-0
lines changed

SidebarApp/app.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
let collapse = document.querySelector('span');
2+
let sidebar = document.querySelector('.side-navbar');
3+
let i = 0;
4+
5+
collapse.addEventListener("click", function(e) {
6+
i++;
7+
if(i % 2 === 0) {
8+
sidebar.style.width = "160px";
9+
} else{
10+
sidebar.style.width = "0px";
11+
}
12+
});

SidebarApp/index.html

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<link href="https://fonts.googleapis.com/css2?family=Montserrat&display=swap" rel="stylesheet">
7+
<link rel="stylesheet" type="text/css" href="style.css">
8+
<title>Document</title>
9+
</head>
10+
<body>
11+
12+
<div class="side-navbar">
13+
<div class="navbar">
14+
<ul>
15+
<li>Home</li>
16+
<li>About</li>
17+
<li>Contact</li>
18+
</ul>
19+
</div>
20+
</div>
21+
22+
<div class="container">
23+
<span role="button"></span>
24+
<h1>This is The website Content</h1>
25+
</div>
26+
27+
<script src="app.js"></script>
28+
</body>
29+
</html>

SidebarApp/style.css

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
body {
2+
margin: 0;
3+
padding:0;
4+
font-family: 'Montserrat', Arial, Helvetica, sans-serif;
5+
}
6+
* {
7+
margin: 0;
8+
padding:0;
9+
}
10+
.container {
11+
margin: 0 auto;
12+
width: 70%;
13+
}
14+
15+
.hidden {
16+
visibility: hidden;
17+
}
18+
19+
.side-navbar {
20+
position: fixed;
21+
height: 100%;
22+
width: 160px;
23+
top: 0;
24+
left: 0;
25+
z-index: 1;
26+
overflow-x: hidden;
27+
background: #efefef;
28+
transition: 0.5s;
29+
}
30+
31+
span {
32+
padding:0;
33+
margin:0;
34+
font-size: 35px;
35+
cursor: pointer;
36+
border-bottom: 1px solid black;
37+
width:100%;
38+
padding-left:130px;
39+
}
40+
41+
li {
42+
list-style-type: none;
43+
font-size: 22px;
44+
padding-left: 20px;
45+
padding-top: 5px;
46+
padding-bottom: 5px;
47+
}
48+
49+
li:hover {
50+
background: #e0e0e0;
51+
}
52+
53+
li:nth-of-type(1) {
54+
margin-top: 5px;
55+
}
56+
57+
.btn {
58+
padding: 5px;
59+
font-size: 20px;
60+
}
61+
62+
@media only screen and (max-width: 600px) {
63+
.container {
64+
margin-top: 0;
65+
width: 100%;
66+
}
67+
68+
}
69+
70+
@media only screen and (max-width: 800px) {
71+
.container {
72+
margin-top: 0;
73+
margin-left: 20%;
74+
}
75+
76+
}

0 commit comments

Comments
 (0)