Skip to content

Instantly share code, notes, and snippets.

@pbrocks
Created January 14, 2015 01:29
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 pbrocks/b22a35892575c9dd3f81 to your computer and use it in GitHub Desktop.
Save pbrocks/b22a35892575c9dd3f81 to your computer and use it in GitHub Desktop.
Simple CSS Menu Transition
<h1>Pure CSS3 menu button</h1>
<div class="menu-box">
<input type="checkbox" id="menu" />
<label for="menu" class="menu-text">
</label>
</div>
<p>Click the menu button to see the effect.</p>
<p>I created this after reading - <a href="http://exisweb.net/menu-eats-hamburger" target="_blank" >Hamburger vs Menu: The Final AB Test</a></p>
@import "compass/css3";
h1{
text-align: center;
}
p{
text-align: center;
}
a{
color: 147ea5;
text-decoration: none;
}
.menu-box{
height:15px;
width:40px;
margin:50px auto;
border: 2px solid #147ea5;
padding: 10px;
position:relative;
overflow: hidden;
}
.menu-box input[type=checkbox] {
display:none;
}
.menu-box label {
cursor:pointer;
height:100%;
width:100%;
position:absolute;
z-index:99;
top:10px;
left:0;
}
.menu-box input ~ .menu-text:before {
height: 100%;
width: 100%;
text-align: center;
font-size: 0.9em;
content: "MENU";
display: block;
@include transition(all, 0.2s, ease-in-out);
}
.menu-box input[type=checkbox]:checked ~ .menu-text:before {
@include transform(translate(0px, -36px) scale(1, 0.2));
@include transition(all, 0.2s, ease-in-out);
}
.menu-box input ~ .menu-text:after {
height: 100%;
width: 100%;
text-align: center;
font-size: 0.9em;
content: "CLOSE";
display: block;
@include transform(translate(0px, 0px) scale(1, 0.2));
@include transition(all, 0.2s, ease-in-out);
}
.menu-box input[type=checkbox]:checked ~ .menu-text:after {
@include transform(translate(0px, -36px) );
@include transition(all, 0.2s, ease-in-out);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment