function togNav() {
document.querySelector("header").classList.toggle('opened');
}
#burger {
position: absolute;
left: calc(100% + 12px);
top: 32px;
width: 45px;
height: 32px;
display: flex;
flex-direction: column;
justify-content: space-between;
transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
cursor: pointer;
padding: 12px;
}
#burger>div {
width: 45px;
height: 6px;
background: #000;
}
header {
background: #fff;
box-shadow: 0 3px 5px -1px rgba(0, 0, 0, 0.1), 0 6px 10px 0 rgba(0, 0, 0, 0.07), 0 1px 18px 0 rgba(0, 0, 0, 0.06);
height: 8rem;
padding: 0 3rem;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: space-between;
}
#menu {
display: flex;
background-color: #fff;
padding: 0;
margin: 0;
}
#menu li {
display: block;
border: 0 solid #eee;
border-right-width: 1px;
}
#menu li:last-child {
border-right-width: 0;
}
#menu a {
display: block;
padding: 1rem;
color: black;
text-decoration: none;
}
#menu a:hover {
color: #8cc63e;
}
body {
margin: 0;
overflow: hidden;
background-color: lightblue;
}
nav {
top: 0;
left: 0;
background-color: white;
}
@media (max-width: 600px) {
nav {
height: 100%;
position: fixed;
width: 250px;
max-width: calc(100vw - 100px);
transform: translateX(-100%);
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s linear;
}
.logo {
transform: translateX(0);
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.opened .logo {
transform: translateX(65vw);
}
header {
flex-direction: column;
align-items: flex-end;
justify-content: center;
transition: box-shadow .3s linear;
}
header.opened {
box-shadow: none;
}
header.opened nav {
transform: translateX(0);
box-shadow: 0 3px 5px -1px rgba(0, 0, 0, 0.2), 0 6px 10px 0 rgba(0, 0, 0, 0.14), 0 1px 18px 0 rgba(0, 0, 0, 0.12);
}
#menu {
flex-direction: column;
padding: 0;
margin: 0;
}
#menu li {
border-bottom: 1px solid #eee;
}
}
<header>
<a href class="logo">Logo</a>
<nav>
<div id="burger" onclick="togNav()">
<div></div>
<div></div>
<div></div>
</div>
<ul id="menu">
<li><a href>Link 1</a></li>
<li><a href>Link 2</a></li>
<li><a href>Link 3</a></li>
<li><a href>Link 4</a></li>
</ul>
</nav>
</header>