Menu Icon Transformation
by Nikhil krishnan
HTML
<header>CSS3 Animated Menu Icon Transformation</header>
<div class="lines-button">
<span class="lines"></span>
<ul>
<li><a href="#">Menu 1</a></li>
<li><a href="#">Menu 2</a></li>
<li><a href="#">Menu 3</a></li>
<li><a href="#">Menu 4</a></li>
</ul>
</div>
<footer>Author: Nikhil Krishnan</footer>
CSS
/*common css style*/
@import url(http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300);
*{
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body{
background-color:#333;
padding:20px;
font-family: 'Open Sans Condensed', sans-serif;
}
header{
background:#eee;
display:block;
padding:10px;
font-size:30px;
color:#333;
margin-bottom:30px;
}
footer{
position:absolute;
left:0px;
bottom:0px;
padding:20px;
width:100%;
text-align: right;
font-size:14px;
color:#717070;
}
/*menu style*/
.lines-button {
padding:5px;
transition: .3s;
cursor: pointer;
border-radius: 2px;
display: inline-block;
margin: 0 1em;
background: none;
position:relative;
}
.lines-button:focus{
border:none;
outline:none;
}
.lines-button .lines {
display: inline-block;
width: 50px;
height: 5px;
background: #ecf0f1;
border-radius: 5px;
transition: 0.3s;
position: relative;
}
button span {
/*display: block;*/
}
.lines-button .lines:before,
.lines-button .lines:after {
display: inline-block;
width: 50px;
height: 5px;
background: #ecf0f1;
border-radius: 5px;
transition: 0.3s;
position: absolute;
left: 0;
content: '';
-webkit-transform-origin: 0 center;
transform-origin: 0 center;
}
.lines-button .lines:before {
top: 10px;
}
.lines-button .lines:after {
top: -10px;
}
.lines-button.close {
-webkit-transform: scale3d(0.8, 0.8, 0.8);
transform: scale3d(0.8, 0.8, 0.8);
}
.lines-button.close .lines {
background: transparent;
}
.lines-button.close .lines:before,
.lines-button.close .lines:after {
-webkit-transform-origin: 50% 50%;
transform-origin: 50% 50%;
top: 0;
width: 50px;
}
.lines-button.close .lines:after {
-webkit-transform: rotate3d(0, 0, 1, -45deg);
transform: rotate3d(0, 0, 1, -45deg);
}
.lines-button.close .lines:before {
-webkit-transform: rotate3d(0, 0, 1, 45deg);
transform: rotate3d(0, 0, 1,...
JavaScript
//Menu Icon Transformation
$('.lines-button').click(function(){
$(this).toggleClass('close');
});