<nav class="nav-main">
<div class="btn-toggle-nav">
<div id='hamburger'>
<a onclick="toggleMenu()" href="#">☰</a>
</div>
</div>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Portfolio</a></li>
<li><a href="#">About Us</a></li>
<li><a href="#">Gallery</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<aside class="nav-sidebar">
<ul>
<li><span>Projects</span></li>
<li><span>Making a Website</span></li>
<li><span>Creating a Video</span></li>
<li><span>SEO Optimizing a Website</span> </li>
</ul>
</aside>
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
/*Start main styles*/
body {
background-color: #d2ccd6;
}
.nav-main: {
position: fixed;
top: 0;
width: 60px;
height: 60px;
background-color: #219797;
display: flex;
flex-wrap: wrap;
z-index: 1000;
}
.btn-toggle-nav {
width: 60px;
height: 60px;
background-color: #219797;
display: flex;
}
#hamburger {
justify-align: center;
item-align: center;
margin: auto;
font-size: 2em;
}
#hamburger a {
text-decoration: none;
color: purple;
}
/* visited link */
#hamburger a:visited {
color: purple;
}
/* mouse over link */
#hamburger a:hover {
color: white;
}
/* selected link */
#hamburger a:active {
color: white;
}
.nav-main {
display: flex;
background-color: white;
}
.nav-main ul li {
display: flex;
display-wrap: wrap;
float: left;
padding-left: 15px;
list-style: none;
line-height: 60px;
}
.nav-main ul li a {
display: flex;
flex-wrap: wrap;
padding-left: 15px;
text-decoration: none;
color: grey;
font-family: arial;
font-size: 1.2em;
}
.nav-main ul li a:hover {
color: purple;
}
.nav-sidebar {
color: white;
width: 50px;
padding: 0 5px;
height: 100vh;
background-color: #1b1b1b;
x-index: 1000;
transition: all 0.3s ease-in-out;
}
.nav-sidebar ul {
padding-top: 15px;
overflow: hidden;
visibility: hidden;
}
.nav-sidebar ul li {
line-height: 60px;
}
.nav-sidebar li span, .nav-sidebar ul li a {
display: block;
height: 60px;
padding: 0 10px;
text-decoration: none;
text-transform: uppercase;
font-size: 16px;
white-space: nowrap;
}
.nav-sidebar ul li a {
background-color: #222;
}
let toggled = false;
function toggleMenu() {
let getSidebarUl = document.querySelector('.nav-sidebar ul');
let getSidebar = document.querySelector('.nav-sidebar');
if (toggled === false) {
getSidebar.style.width = "250px";
getSidebarUl.style.visibility = 'visible'
toggled = true;
} else {
getSidebar.style.width = "50px";
getSidebarUl.style.visibility = 'hidden'
toggled = false;
}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.