-
Notifications
You must be signed in to change notification settings - Fork 0
/
sideNavigation.html
134 lines (125 loc) · 4.76 KB
/
sideNavigation.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<!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>Side Navigation</title>
<style>
*{
font-family: sans-serif;
}
.sidenav{
height: 100%;
width: 0;/*Change this with javascript */
position: fixed;
z-index: 1; /*Stay in top */
top: 0;
left: 0;
background-color: #111;
overflow-x: hidden; /*Disable horizontal scroll */
transition: 0.5s;
}
.sidenav a{
padding: 8px 8px 8px 32px;
text-decoration: none;
font-size: 25px;
color: #818181;
display: block;
transition: 0.3s;
}
.sidenav a:hover{
color: #f1f1f1;
}
.sidenav .closebtn{
position: absolute;
top: 0;
right: 25px;
font-size: 36px;
margin-left: 50px;
}
#open button{
cursor: pointer;
font-size: 17px;
padding: 8px;
background: none;
background-color: deeppink;
color: white;
border: none;
width: 150px;
border-radius: 50px;
outline: none;
}
#main, #open{
transition: 0.5s;
}
@media screen and (max-width: 450px){
.sidenav {padding-top: 15px;}
.sidenav a{font-size: 18px;}
}
</style>
</head>
<body>
<!-- Sidenav overlay
Sidenav overlay without animation
Sidenav push(off-canvas)
Sidenav push w/opacity
Sidenav full-width -->
<div id="mySidenav" class="sidenav">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
<a href="#">About</a>
<a href="#">Services</a>
<a href="#">Clients</a>
<a href="#">Contact</a>
</div>
<!-- Use any element to open the sidenav -->
<span id="open" onclick="openNav()"><button>Open Sidenav</button></span>
<!-- Add all page content inside this div if you want the side nav to push page content to right(not used if you only want the sidenav to sit on top of the page) -->
<div id="main">
<h1>About us</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Minus ea voluptates et accusamus rem tempora magnam pariatur? Neque ab pariatur omnis odit, fuga veniam sed dolore, quo, voluptatibus dolorem tempore mollitia ipsam iste ipsum impedit dicta molestiae commodi architecto accusamus quae at quibusdam sapiente. Perspiciatis.</p>
</div>
<script>
// // Sidenav Overlay Example
// function openNav(){
// document.getElementById("mySidenav").style.width= "250px";
// }
// function closeNav(){
// document.getElementById("mySidenav").style.width= "0";
// }
// Sidenav Push Content Example
// function openNav(){
// document.getElementById("mySidenav").style.width= "250px";
// document.getElementById("main").style.marginLeft= "250px";
// document.getElementById("open").style.marginLeft= "250px";
// }
// function closeNav(){
// document.getElementById("mySidenav").style.width= "0";
// document.getElementById("main").style.marginLeft= "0";
// document.getElementById("open").style.marginLeft= "0";
// }
// Sidenav Push content w/opacity
function openNav(){
document.getElementById("mySidenav").style.width= "250px";
document.getElementById("main").style.marginLeft= "250px";
document.getElementById("open").style.marginLeft= "250px";
document.getElementById("open").style.display= "none";
document.body.style.backgroundColor= "rgba(0,0,0,0.4)";
}
function closeNav(){
document.getElementById("mySidenav").style.width= "0";
document.getElementById("main").style.marginLeft= "0";
document.getElementById("open").style.marginLeft= "0";
document.getElementById("open").style.display= "block";
document.body.style.backgroundColor= "white";
}
// //Sidenav full-width
// function openNav(){
// document.getElementById("mySidenav").style.width= "100%";
// }
// function closeNav(){
// document.getElementById("mySidenav").style.width= "0";
// }
</script>
</body>
</html>