<div class="mobile-wrapper">
<div class="mobile-container">
<div class="content">
<nav>
<input type="checkbox" id="hamburger1" />
<label for="hamburger1"></label>
<ul class="nav-links">
<li><a href="#">about us</a></li>
<li><a href="#">products</a></li>
<li><a href="#">media</a></li>
<li><a href="#">contact us</a></li>
</ul>
</nav>
</div>
</div>
</div>
@import url('https://fonts.googleapis.com/css?family=Nunito:400,700');
$nav-links: about, products, media, contact us;
* {
box-sizing: border-box;
}
html,
body {
font-family: 'Nunito', sans-serif;
height: 100%;
width: 100%;
}
body {
background: #404040;
display: table;
}
a {
text-decoration: none;
}
// Mobile mockup design
.mobile-wrapper {
display: table-cell;
text-align: center;
vertical-align: middle;
.mobile-container {
background: #fff;
border: 20px solid #666;
border-bottom-width: 80px;
border-radius: 20px;
box-shadow: 0 0 10px 10px rgba(0, 0, 0, .1);
display: inline-block;
height: 520px;
margin: 0 30px;
position: relative;
width: 320px;
&::before {
background: #555;
border: 2px solid #4a4a4a;
border-radius: 50%;
bottom: -67px;
content: '';
display: block;
height: 50px;
left: 50%;
position: absolute;
width: 50px;
transform: translateX(-50%);
z-index: 1;
}
}
}
// Inner mobile canvas
.content {
background: aliceblue;
display: block;
height: 100%;
overflow: hidden;
width: 100%;
nav {
background: #fff;
border-bottom: 1px solid #ddd;
height: 60px;
position: relative;
}
.nav-links {
display: block;
position: absolute;
top: 60px;
left: 0;
width: 100%;
// Dark overlay on open nav
&::before {
background: rgba(0, 0, 0, .5);
content: '';
height: 100vh;
left: 0;
top: 0;
position: absolute;
opacity: 0;
visibility: hidden;
width: 100%;
transition: all .3s;
}
li {
border-bottom: 1px solid #ddd;
opacity: 0;
visibility: hidden;
transform: translateY(-20px);
transition: all .3s;
a {
background: #fff;
color: #404040;
display: block;
font-size: 18px;
font-weight: 700;
padding: 12px 20px;
text-align: left;
width: 100%;
transition: all .3s;
&:hover {
color: coral;
}
}
}
}
}
// Hidden checkbox to triger mobile nav
input[type="checkbox"] {
position: absolute;
opacity: 0;
visibility: hidden;
// Nav open styling - achieved with ':checked' selector
&:checked + label {
border: 4px solid silver;
border-radius: 50%;
height: 28px;
top: 16px;
left: 18px;
width: 28px;
transform: rotate(-135deg);
&::before {
background: silver;
top: 8px;
left: 4px;
width: 12px;
}
&::after {
background: silver;
opacity: 1;
top: 8px;
left: 4px;
visibility: visible;
width: 12px;
}
&:hover {
border-color: coral;
&::before,
&::after {
background: coral;
}
}
}
&:checked ~ .nav-links {
&::before {
opacity: 1;
visibility: visible;
}
li {
opacity: 1;
visibility: visible;
transform: translateY(0);
@for $i from 1 through length($nav-links) {
&:nth-child(#{$i}) {
transition-delay: ($i - 1)/10+s;
}
}
}
}
}
// Styling of the linked label element
label {
background: none transparent;
border: 4px solid coral;
border-left: 0 solid transparent;
border-right: 0 solid transparent;
cursor: pointer;
display: block;
height: 24px;
position: absolute;
top: 18px;
left: 20px;
width: 24px;
transition: all .2s;
&::before {
background: coral;
content: '';
height: 4px;
left: 0;
position: absolute;
top: 6px;
width: 24px;
transition: all .2s;
}
&::after {
background: coral;
content: '';
height: 4px;
left: 0;
position: absolute;
top: 6px;
opacity: 0;
visibility: hidden;
width: 100%;
transform: rotate(90deg);
transition: all .2s;
}
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.