.page
.page__top
.menu#menu
input.menu__trigger.menu__trigger_show#show-menu(type="radio", name="menu-trigger")
input.menu__trigger.menu__trigger_hide#hide-menu(type="radio", name="menu-trigger")
.menu__overlay
label.menu__btn(for="show-menu")
.menu__btn-icon
.menu__list
label.menu__list-item(for="hide-menu")
span.menu__list-text Home
label.menu__list-item(for="hide-menu")
span.menu__list-text About
label.menu__list-item(for="hide-menu")
span.menu__list-text Services
label.menu__list-item(for="hide-menu")
span.menu__list-text Contact
.page__content
.card
.card__avatar
.card__name
.card__title
.card__description
View Compiled
@use postcss-nested;
*, *:before, *:after {
box-sizing: border-box;
tap-highlight-color: rgba(0, 0, 0, 0);
}
body {
background: #f2e274;
font: 14px/1.2 'Open Sans',helvetica, sans-serif;
}
.page {
height: 440px;
width: 260px;
background: #fff;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
border-radius: 6px;
overflow: hidden;
box-shadow: 1px 3px 6px rgba(0, 0, 0, .3);
&__top {
height: 56px;
margin-bottom: 20px;
}
}
.menu {
&__trigger {
position: absolute;
top: 0;
left: 0;
opacity: 0;
width: 0;
height: 0;
&_show {
&:checked {
& ~ .menu__btn {
transition: transform .4s ease-in-out,
opacity .1s ease-in-out .5s;
transform: scaleX(25);
opacity: 0;
.menu__btn-icon {
transition: background .3s ease-in-out;
background: #cbd9ec;
}
}
& ~ .menu__list {
transition: opacity .1s ease-in-out .4s,
box-shadow .4s ease-in-out .5s,
border .4s ease-in-out .5s;
opacity: 1;
transform: translate(0, 0);
border-bottom-color: #cbd9ec;
box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
.menu__list-item {
transition: height .5s ease-in-out .5s;
height: 60px;
&:nth-child(1) {
.menu__list-text {
transition: transform .15s ease-in-out .8s,
opacity .15s ease-in-out .8s;
}
}
&:nth-child(2) {
.menu__list-text {
transition: transform .15s ease-in-out .9s,
opacity .15s ease-in-out .9s;
}
}
&:nth-child(3) {
.menu__list-text {
transition: transform .15s ease-in-out 1s,
opacity .15s ease-in-out 1s;
}
}
&:nth-child(4) {
.menu__list-text {
transition: transform .15s ease-in-out 1.1s,
opacity .15s ease-in-out 1.1s;
}
}
}
.menu__list-text {
transform: translate(20px, -50%);
opacity: 1;
}
}
& ~ .menu__overlay {
transition: transform .1s ease-in-out .7s,
opacity .25s ease-in-out .8s;
opacity: 1;
transform: translate(0, 0);
}
}
}
}
&__btn {
transition: opacity .1s ease-in-out .4s,
transform .4s ease-in-out .5s;
width: 20px;
height: 16px;
position: absolute;
top: 20px;
left: 20px;
cursor: pointer;
z-index: 10;
&-icon {
transition: background .4s ease-in-out .6s;
position: absolute;
width: 100%;
height: 2px;
top: 50%;
margin-top: -1px;
background: #8a9db1;
z-index: 10;
&:before,
&:after {
content: '';
width: 100%;
height: 100%;
background: inherit;
position: absolute;
left: 0;
}
&:before {
top: -7px;
}
&:after {
bottom: -7px;
}
}
}
&__list {
transition: border .4s ease-in-out,
box-shadow .4s ease-in-out,
opacity .1s ease-in-out .5s,
transform .1s ease-in-out .8s;
position: absolute;
opacity: 0;
top: 0;
left: 0;
width: 100%;
z-index: 20;
padding: 0;
transform: translate(0, -100%);
background: #fff;
border-bottom: 2px solid rgba(0, 0, 0, 0);
box-shadow: none;
&-item {
transition: height .5s ease-in-out;
border-bottom: 2px solid #cbd9ec;
height: 7px;
display: block;
cursor: pointer;
position: relative;
&:active {
background: #364656;
color: #fff;
}
&:first-child {
height: 22px;
}
&:last-child {
border-bottom: none;
}
&:nth-child(4) {
.menu__list-text {
transition: transform .1s ease-in-out,
opacity .1s ease-in-out;
}
}
&:nth-child(3) {
.menu__list-text {
transition: transform .1s ease-in-out .1s,
opacity .1s ease-in-out .1s;
}
}
&:nth-child(2) {
.menu__list-text {
transition: transform .1s ease-in-out .2s,
opacity .1s ease-in-out .2s;
}
}
&:nth-child(1) {
.menu__list-text {
transition: transform .1s ease-in-out .3s,
opacity .1s ease-in-out .3s;
}
}
}
&-text {
position: absolute;
top: 50%;
left: 0;
transform: translate(-20px, -50%);
opacity: 0;
}
}
&__overlay {
transition: opacity .25s ease-in-out,
transform .1s ease-in-out .25s;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 5;
background: rgba(138, 157, 177, .3);
opacity: 0;
transform: translate(0, -100%)
}
}
.card {
text-align: center;
display: flex;
align-items: center;
flex-direction: column;
padding: 20px;
&__avatar {
background: #e4f3fa;
border-radius: 50%;
width: 120px;
height: 120px;
margin-bottom: 10px;
}
&__name {
width: 120px;
height: 14px;
background: #e4f3fa;
margin-bottom: 10px;
border-radius: 3px;
}
&__title {
width: 160px;
height: 14px;
background: #e4f3fa;
margin-bottom: 20px;
border-radius: 3px;
}
&__description {
background: #e4f3fa;
height: 136px;
width: 100%;
border-radius: 3px;
}
}
View Compiled
/**
Pure css implementation of the concept:
https://dribbble.com/shots/2286361-Hamburger-Menu-Animation
**/
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.