A Pen by Mike Hacker on CodePen.
Last active
October 16, 2019 22:11
-
-
Save mhackersu/5731f4d214ab3f2b6fabd324f07e3eff to your computer and use it in GitHub Desktop.
CSS Drawer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<content> | |
<section class="msg"> | |
<div>ux dev</div> | |
</section> | |
<input id="hamburger" class="hamburger" type="checkbox"/> | |
<label class="hamburger" for="hamburger"> | |
<i></i> | |
<text> | |
<close>close</close> | |
<open>menu</open> | |
</text> | |
</label> | |
<section class="drawer-list"> | |
<ul> | |
<li><a href="#">Home</a></li> | |
<li><a href="#">Qualatative UX</a></li> | |
<li><p href="#">Prototypes</p></li> | |
<li><p href="#">Customer Feedback</p></li> | |
<li><a href="#">Quantatative UX</a></li> | |
<li><p href="#">Visual Regression</p></li> | |
<li><p href="#">Behavior Driven Development (BDD)</p></li> | |
<li><a href="#">Design</a></li> | |
<li><p href="#">Color and Typography</p></li> | |
<li><p href="#">Atomic Design</p></li> | |
<li><p href="#">Visual Composition</p></li> | |
</ul> | |
</section> | |
</content> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 404 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mixin transition { | |
@for $i from 1 through 50 { | |
&:nth-child(#{$i}) { | |
transition: transform 1s #{$i * 0.08}s cubic-bezier(0.29, 1.4, 0.44, 0.96); | |
} | |
} | |
} | |
@mixin alpha-attribute($attribute, $color, $background) { | |
$percent: alpha($color) * 100%; | |
$opaque: opacify($color, 1); | |
$solid-color: mix($opaque, $background, $percent); | |
#{$attribute}: $solid-color; | |
#{$attribute}: $color; | |
} | |
html { | |
font-family: "Lato", sans-serif; | |
} | |
body { | |
margin: 0; | |
overflow-x: hidden; | |
height: 100vh; | |
width: 100vw; | |
} | |
ul { | |
list-style: none; | |
margin: 0; | |
padding: 0; | |
} | |
$main: #1184f0; | |
$text: #fefefe; | |
$contrast: darken($main, 10%); | |
.msg { | |
font-family: "Pacifico", cursive; | |
font-size: 8vw; | |
display: flex; | |
flex-direction: column; | |
justify-content: center; | |
height: 100%; | |
max-height: 100%; | |
max-width: 100%; | |
align-items: center; | |
color: $text; | |
background-color: $main; | |
} | |
.features { | |
font-family: "Lato", sans-serif; | |
font-size: 1rem; | |
text-transform: uppercase; | |
li { | |
width: 100%; | |
text-align: center; | |
padding: 0.25em; | |
} | |
} | |
.drawer-list { | |
position: fixed; | |
right: 0; | |
top: 0; | |
height: 100vh; | |
width: 100vw; | |
transform: translate(100vw, 0); | |
/* ie workaround */ | |
-ms-transform: translatex(-100vw); | |
box-sizing: border-box; | |
pointer-events: none; | |
padding-top: 125px; | |
transition: width 475ms ease-out, transform 450ms ease, | |
border-radius 0.8s 0.1s ease; | |
border-bottom-left-radius: 100vw; | |
@include alpha-attribute("background-color", rgba($contrast, 0.8), white); | |
@media (min-width: 768px) { | |
width: 40vw; | |
} | |
ul { | |
height: 100%; | |
width: 100%; | |
margin: 0; | |
padding: 0; | |
overflow: auto; | |
overflow-x: hidden; | |
pointer-events: auto; | |
} | |
li { | |
list-style: none; | |
text-transform: uppercase; | |
pointer-events: auto; | |
white-space: nowrap; | |
box-sizing: border-box; | |
transform: translatex(100vw); | |
/* ie workaround */ | |
-ms-transform: translatex(-100vw); | |
&:last-child { | |
margin-bottom: 1em; | |
} | |
a { | |
text-decoration: none; | |
color: $text; | |
text-align: center; | |
display: block; | |
padding: 0.5rem; | |
font-size: calc(24px - 0.5vw); | |
@media (min-width: 768px) { | |
text-align: right; | |
padding: 0.5rem; | |
} | |
} | |
&:hover { | |
cursor: pointer; | |
@include alpha-attribute("background-color", rgba($main, 0.5), white); | |
} | |
} | |
p { | |
text-decoration: none; | |
color: $text; | |
text-align: center; | |
display: block; | |
padding: 1rem; | |
margin-right: 10px; | |
font-size: calc(18px - 0.5vw); | |
@media (min-width: 768px) { | |
text-align: right; | |
padding: 0.5rem; | |
} | |
} | |
} | |
input.hamburger { | |
display: none; | |
&:checked { | |
& ~ .drawer-list { | |
transform: translatex(0); | |
border-bottom-left-radius: 0; | |
li { | |
transform: translatex(0); | |
@include transition; | |
a { | |
padding-right: 15px; | |
} | |
} | |
} | |
& ~ label { | |
> i { | |
background-color: transparent; | |
transform: rotate(90deg); | |
&:before { | |
transform: translate(-50%, -50%) rotate(315deg); | |
} | |
&:after { | |
transform: translate(-50%, -50%) rotate(-315deg); | |
} | |
} | |
close { | |
color: $text; | |
width: 100%; | |
} | |
open { | |
color: rgba(0, 0, 0, 0); | |
width: 0; | |
} | |
} | |
} | |
} | |
label.hamburger { | |
z-index: 9999; | |
position: relative; | |
display: block; | |
height: 50px; | |
width: 50px; | |
&:hover { | |
cursor: pointer; | |
} | |
text { | |
close, | |
open { | |
text-transform: uppercase; | |
font-size: 0.8em; | |
align-text: center; | |
position: absolute; | |
transform: translateY(50px); | |
text-align: center; | |
overflow: hidden; | |
transition: width 0.25s 0.35s, color 0.45s 0.35s; | |
} | |
close { | |
color: rgba(0, 0, 0, 0); | |
right: 0; | |
width: 0; | |
} | |
open { | |
color: $text; | |
width: 100%; | |
} | |
} | |
> i { | |
position: absolute; | |
width: 100%; | |
height: 2px; | |
top: 50%; | |
background-color: $text; | |
pointer-events: auto; | |
transition-duration: 0.35s; | |
transition-delay: 0.35s; | |
&:before, | |
&:after { | |
position: absolute; | |
display: block; | |
width: 100%; | |
height: 2px; | |
left: 50%; | |
background-color: $text; | |
content: ""; | |
transition: transform 0.35s; | |
transform-origin: 50% 50%; | |
} | |
&:before { | |
transform: translate(-50%, -14px); | |
} | |
&:after { | |
transform: translate(-50%, 14px); | |
} | |
} | |
} | |
label.hamburger { | |
position: fixed; | |
top: 15px; | |
right: 15px; | |
} | |
/** | |
SCROLLBAR STYLE FOR IE | |
*/ | |
body { | |
scrollbar-base-color: rgb(19, 138, 114); | |
scrollbar-3dlight-color: #fff; | |
scrollbar-highlight-color: #1abc9c; | |
scrollbar-track-color: #fff; | |
scrollbar-arrow-color: #1abc9c; | |
scrollbar-shadow-color: #1abc9c; | |
scrollbar-dark-shadow-color: #1abc9c; | |
-ms-overflow-style: -ms-autohiding-scrollbar; | |
} | |
.icon { | |
display: inline-block; | |
width: 5vw; | |
height: 4vw; | |
stroke-width: 0; | |
stroke: currentColor; | |
fill: currentColor; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment