Skip to content

Instantly share code, notes, and snippets.

@valerysntx
Last active August 29, 2015 14:05
Show Gist options
  • Save valerysntx/53f1fd3d8f00d1cb3bed to your computer and use it in GitHub Desktop.
Save valerysntx/53f1fd3d8f00d1cb3bed to your computer and use it in GitHub Desktop.
animated mobile button - http://codepen.io/d_kim/pen/mBfeL
$(document).ready(function() {
$('.box').click(function() {
$(this).toggleClass('active');
});
});
.box {
width: 50px;
height: 50px;
margin: 3em auto;
background: #eee;
border-radius: .4em;
cursor: pointer;
transition: all .3s ease;
&:hover {
background: lighten(#eee, 5%);
}
}
.btn, .btn:before, .btn:after {
width: 6px;
height: 6px;
border-radius: 50%;
background: #555;
transition: all .3s ease;
}
.btn {
margin: 0 auto;
position: relative;
top: 22px;
&:before, &:after {
content: '';
position: absolute;
}
&:before {
left: -12px;
}
&:after {
left: 12px;
}
}
.box.active {
.btn, .btn:before, .btn:after {
height: 30px;
border-radius: 3px;
}
.btn {
transform: translateY(-11px);
background: transparent;
}
.btn:before {
transform: translateX(12px) rotate(225deg);
}
.btn:after {
transform: translateX(-12px) rotate(-225deg);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment