Skip to content

Instantly share code, notes, and snippets.

@mikejakobsen
Created August 22, 2017 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikejakobsen/081b01fa84dd1ff3d0d5f0b70dc59ee4 to your computer and use it in GitHub Desktop.
Save mikejakobsen/081b01fa84dd1ff3d0d5f0b70dc59ee4 to your computer and use it in GitHub Desktop.
HTML
<nav class="mobile">
<button>Toggle</button>
<div>
<a href="#">Mobile 1</a>
<a href="#">Mobile 2</a>
<a href="#">Mobile 3</a>
<a href="#">Mobile 4</a>
</div>
</nav>
CSS
html
height: 2000px;
.mobile
display: none;
position: fixed;
width: 100%;
top: 0;
div
display: none;
button
position: absolute;
top: 15px;
right: 15px;
border: 0;
text-indent: 200%;
overflow: hidden;
background: rgba(255,255,255,.8) url(http://i.imgur.com/vKRaKDX.png) center no-repeat;
border: 1px solid #ddd;
border-radius: 3px;
background-size: 80%;
width: 30px;
height: 30px;
outline: none;
transition: all 400ms ease;
&.expanded
transform: rotate(90deg);
background-color: transparent;
border: 0;
a
display: block;
a
background: #eee;
text-align: center;
padding: 20px 0;
border-bottom: 1px solid #ddd;
text-decoration: none;
color: #222;
font-weight: bold;
&:hover, &:active, &:focus
background: darken(#eee, 3%);
.desktop
display: block;
overflow: hidden;
a
width: 25%;
float: left;
border-right: 1px solid #ddd;
box-sizing: border-box;
&:last-child
border-right: none;
article
padding: 0 30px 15px;
@media (max-width: 800px)
.mobile
display: block;
JS
html
height: 2000px;
.mobile
display: none;
position: fixed;
width: 100%;
top: 0;
div
display: none;
button
position: absolute;
top: 15px;
right: 15px;
border: 0;
text-indent: 200%;
overflow: hidden;
background: rgba(255,255,255,.8) url(http://i.imgur.com/vKRaKDX.png) center no-repeat;
border: 1px solid #ddd;
border-radius: 3px;
background-size: 80%;
width: 30px;
height: 30px;
outline: none;
transition: all 400ms ease;
&.expanded
transform: rotate(90deg);
background-color: transparent;
border: 0;
a
display: block;
a
background: #eee;
text-align: center;
padding: 20px 0;
border-bottom: 1px solid #ddd;
text-decoration: none;
color: #222;
font-weight: bold;
&:hover, &:active, &:focus
background: darken(#eee, 3%);
.desktop
display: block;
overflow: hidden;
a
width: 25%;
float: left;
border-right: 1px solid #ddd;
box-sizing: border-box;
&:last-child
border-right: none;
article
padding: 0 30px 15px;
@media (max-width: 800px)
.mobile
display: block;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment