Skip to content

Instantly share code, notes, and snippets.

@omniosi
Created February 28, 2014 19:43
Show Gist options
  • Save omniosi/9278323 to your computer and use it in GitHub Desktop.
Save omniosi/9278323 to your computer and use it in GitHub Desktop.
a CSS-animated menu/close button inspired by http://www.hugeinc.com/
*{
-webkit-transition: opacity 100ms ease;
transition: opacity 100ms ease;
-webkit-transition: all 500ms ease;
transition: all 500ms ease;
}
#box{
background:lightgrey;
width:60px;
height:60px;
}
ul{
padding:15px;
}
li{
list-style:none;
width:100%;
height:6px;
background:#000;
margin-bottom:6px;
position:relative;
}
li:first-child{
-webkit-transform:rotate(0deg);
transform:rotate(0deg);
top:0px;
}
li:last-child{
-webkit-transform:rotate(0deg);
transform:rotate(0deg);
top:0px;
}
.open li{
opacity:0;
}
.open li:first-child{
-webkit-transform:rotate(45deg);
transform:rotate(45deg);
top:12px;
opacity:1;
}
.open li:last-child{
-webkit-transform:rotate(-45deg);
transform:rotate(-45deg);
top:-12px;
opacity:1;
}
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<div id="box">
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</body>
</html>
$(document).ready(function(){
$('ul').on('click',function(){
$('ul').toggleClass('open');
});
});
@AleksyukAleksander
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment