How to create a reveal icon inside button on hover in TB3. I tried to mimic this behavior using CSS transitions and position property. But I essentially need is to have a separate background color for icon and button. Here is what I am doing right now.
HTML Markup
<button class="btn btn-dark icon-revealed">
<span class="glyphicon glyphicon-cloud-download"></span>
Download
</button>
CSS Code
.btn.icon-revealed > span {
left: -30px;
width: 0;
-webkit-transition: all .5s ease-in-out;
-moz-transition: all .5s ease-in-out;
-o-transition: all .5s ease-in-out;
-ms-transition: all .5s ease-in-out;
}
.btn.icon-revealed:hover > span {
width: 20%;
-webkit-transform: translate(2em,0);
-moz-transform: translate(2em,0);
-o-transform: translate(2em,0);
-ms-transform: translate(2em,0);
}
What I want to Achieve
Notice the background color of icon and button changed on hover state. I could not able to do that. How can I achieve this in TB3?
Here's an alternative way that smooths out the transition.
.btn-dark {
border: none;
font-family: inherit;
font-size: inherit;
color: #fff;
background: none;
padding: 15px 30px;
display: inline-block;
text-transform: uppercase;
letter-spacing: 1px;
font-weight: 500;
outline: none;
position: relative;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
transition: all 0.3s;
}
.btn-dark:after {
content: '';
position: absolute;
z-index: -1;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
transition: all 0.3s;
}
.btn-icon {
background: #4E7878;
color: #fff;
line-height: 20px;
font-size: 14px;
overflow: hidden;
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
backface-visibility: hidden;
}
.btn-icon span {
display: inline-block;
width: 100%;
height: 100%;
-webkit-transition: all 0.3s;
-webkit-backface-visibility: hidden;
-moz-transition: all 0.3s;
-moz-backface-visibility: hidden;
transition: all 0.3s;
backface-visibility: hidden;
}
.btn-icon:before {
background: #4A6B6B;
position: absolute;
height: 100%;
width: 30%;
line-height: 2.5;
font-size: 150%;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
transition: all 0.3s;
}
.btn-download:hover span {
-webkit-transform: translateX(25%);
-moz-transform: translateX(25%);
-ms-transform: translateX(25%);
transform: translateX(25%);
color: #fff;
}
.btn-download:before {
left: -100%;
top: 0;
}
.btn-download:hover:before {
left: 0%;
}
.icon-reveal:before {
content: "\e197";
font-family: 'Glyphicons Halflings';
color: #fff;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<hr>
<div class="container">
<button class="btn-dark btn-icon btn-download icon-reveal"><span> Download</span>
</button>
</div>
You can create that effect using multiple backgrounds with linear-gradient. Code explanantion in comments
.btn.icon-revealed {
margin: 10px; /* Added for SO snippet, not required */
width: 115px; /* Added fixed width for avoiding jump */
}
.btn.icon-revealed > span {
left: -40px;
width: 0;
-webkit-transition: all .5s ease-in-out;
-moz-transition: all .5s ease-in-out;
-o-transition: all .5s ease-in-out;
-ms-transition: all .5s ease-in-out;
}
.btn.icon-revealed:hover > span {
width: 20%;
-webkit-transform: translate(2.5em, 0);
-moz-transform: translate(2.5em, 0);
-o-transform: translate(2.5em, 0);
-ms-transform: translate(2.5em, 0);
}
/* Added code */
.btn.icon-revealed {
background: #53777A;
color: #fff;
}
.btn.icon-revealed:hover {
background: linear-gradient(to right, #4B6B6E 0%, #4B6B6E 30%, #53777A 30%);
/* Start color---^, End at 30%-^, ^-- Start second color */
color: #fff;
}
.btn.icon-revealed:hover .text {
padding-left: 5px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<button class="btn btn-dark icon-revealed">
<span class="glyphicon glyphicon-cloud-download"></span>
<span class="text">Download</span>
</button>
Related
I have some css for a custom checkbox.
.test label {
position: absolute;
width: 13px;
height: 13px;
background-color: #ff0000;
color: #ffffff;
-webkit-transition: background-color 1s ease-out 1s;
-moz-transition: background-color 1s ease-out 1s;
-o-transition: background-color 1s ease-out 1s;
transition: background-color 1s ease-out 1s;
}
.test input[type=checkbox]:checked + label {
background-color:#ff0000;
-webkit-transition: background-color 1s ease-out 1s;
-moz-transition: background-color 1s ease-out 1s;
-o-transition: background-color 1s ease-out 1s;
transition: background-color 1s ease-out 1s;
}
.test label:after {
position: absolute;
bottom: 5px;
width: 12px;
height: 5px;
opacity: 0;
content: '';
background: transparent;
border: 2px solid #ffffff;
border-top: none;
border-right: none;
-webkit-transform: rotate(-50deg);
-moz-transform: rotate(-50deg);
-ms-transform: rotate(-50deg);
-o-transform: rotate(-50deg);
transform: rotate(-50deg);
filter: alpha(opacity=0);
}
.test input[type=checkbox] {
visibility: hidden;
}
.test input[type=checkbox]:checked + label:after {
opacity: 1;
filter: alpha(opacity=100);
}
<div class="test">
<input type="checkbox" value="none" id="test1" name="check">
<label for="test1">This text should be inline from left to right or the right of the checkbox</label>
</div>
The issue is that the text is all wrapping down in a width of 13 pixels and I need it on the right of the checkbox to stretch.
How can I fix this code?
Your code is completely incomprehensible, what is it that you're trying to achieve?
input[type="checkbox"]:checked+label {
background-color: #0a0;
}
label {
display: block;
position: relative;
padding-left: 30px;
margin-bottom: 12px;
line-height: 26px;
cursor: pointer;
font-size: 20px;
}
/* Hiding the checkbox */
input[type=checkbox] {
visibility: hidden;
}
/* Show a custom checkbox instead */
.custom {
position: absolute;
top: 0;
left: 0;
height: 25px;
width: 25px;
background-color: black;
-webkit-transition: background-color .2s ease-out .2s;
-moz-transition: background-color .2s ease-out .2s;
-o-transition: background-color .2s ease-out .2s;
transition: background-color .2s ease-out .2s;
}
label:hover input~.custom {
background-color: gray;
}
label input:active~.custom {
background-color: white;
}
label input:checked~.custom {
background-color: orange;
}
/* Checkmark to be shown in checkbox */
.custom:after {
content: "";
position: absolute;
display: none;
}
/* Display checkmark when checked */
label input:checked~.custom:after {
display: block;
}
label .custom:after {
left: 8px;
bottom: 5px;
width: 6px;
height: 12px;
border: solid white;
border-width: 0 4px 4px 0;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
<label for="check1">
Check this box
<input id="check1" type="checkbox">
<span class="custom"></span>
</label>
<label for="check2">
Or this one
<input id="check2" type="checkbox">
<span class="custom"></span>
</label>
<label for="check3">
Or all three
<input id="check3" type="checkbox">
<span class="custom"></span>
</label>
Good afternoon.
I'm having a problem changing the background color of the checkboxes that are selected.
CheckBox to change
I've seen options on the internet and some questions right here in the stack. But none of them were successful. Below is the DOM image where the elements are inserted.
Dom about element
The last code I tested was this and it still didn't work
input[type=checkbox]:checked:after{
background-color: red !important;
color: blue !important;
}
Aimed to have a background in this color # FFEA00 when checked and the arrow to be # 000 when checked.
Best regards and thanks for the help
Yellow background when checked, black arrow when checked. It's here:
.checkbox-label {
display: block;
position: relative;
margin: auto;
cursor: pointer;
font-size: 22px;
line-height: 24px;
height: 24px;
width: 24px;
clear: both;
}
.checkbox-label input {
position: absolute;
opacity: 0;
cursor: pointer;
}
.checkbox-label .checkbox-custom {
position: absolute;
top: 0px;
left: 0px;
height: 24px;
width: 24px;
background-color: transparent;
border-radius: 5px;
transition: all 0.3s ease-out;
-webkit-transition: all 0.3s ease-out;
-moz-transition: all 0.3s ease-out;
-ms-transition: all 0.3s ease-out;
-o-transition: all 0.3s ease-out;
border: 2px solid #000;
}
.checkbox-label input:checked ~ .checkbox-custom {
background-color: #FFEA00;
border-radius: 5px;
-webkit-transform: rotate(0deg) scale(1);
-ms-transform: rotate(0deg) scale(1);
transform: rotate(0deg) scale(1);
opacity:1;
border: 2px solid #000;
}
.checkbox-label .checkbox-custom::after {
position: absolute;
content: "";
left: 12px;
top: 12px;
height: 0px;
width: 0px;
border-radius: 5px;
border: solid #000;
border-width: 0 3px 3px 0;
-webkit-transform: rotate(0deg) scale(0);
-ms-transform: rotate(0deg) scale(0);
transform: rotate(0deg) scale(0);
opacity:1;
transition: all 0.3s ease-out;
-webkit-transition: all 0.3s ease-out;
-moz-transition: all 0.3s ease-out;
-ms-transition: all 0.3s ease-out;
-o-transition: all 0.3s ease-out;
}
.checkbox-label input:checked ~ .checkbox-custom::after {
-webkit-transform: rotate(45deg) scale(1);
-ms-transform: rotate(45deg) scale(1);
transform: rotate(45deg) scale(1);
opacity:1;
left: 8px;
top: 3px;
width: 6px;
height: 12px;
border: solid #000000;
border-width: 0 2px 2px 0;
background-color: transparent;
border-radius: 0;
}
<div class="checkbox-container">
<label class="checkbox-label">
<input type="checkbox">
<span class="checkbox-custom"></span>
</label>
</div>
I am trying to use below buttons for my web pages. How to use it for setting hyper link in these buttons ?
#import url('http://fonts.googleapis.com/css?family=Roboto+Condensed');
.preserve-3d {
transform-style: preserve-3d;
-webkit-transform-style: preserve-3d;
}
body {
padding: 0;
margin: 0;
border: 0;
overflow-x: none;
background-color: #ffffff;
font-family: Roboto Condensed, sans-serif;
font-size: 12px;
font-smooth: always;
-webkit-font-smoothing: antialiased;
}
.back {
width: 33%;
height: 200px;
float: left;
background-color: #eeeeee;
border: 10px;
border-color: #ffffff;
border-style: solid;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
counter-increment: bc;
padding: 0px 5px 5px 5px;
}
.back:before {
content: counter(bc) "_";
position: absolute;
padding: 10px;
}
#media screen and (max-width: 1260px) {
.back {
width: 50%;
}
}
#media screen and (max-width: 840px) {
.back {
width: 100%;
}
}
.button_base {
margin: 0;
border: 0;
font-size: 18px;
position: relative;
top: 50%;
left: 50%;
margin-top: -25px;
margin-left: -100px;
width: 200px;
height: 50px;
text-align: center;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-user-select: none;
cursor: default;
}
.button_base:hover {
cursor: pointer;
}
/* ### ### ### 01 */
.b01_simple_rollover {
color: #000000;
border: #000000 solid 1px;
padding: 10px;
background-color: #ffffff;
}
.b01_simple_rollover:hover {
color: #ffffff;
background-color: #000000;
}
/* ### ### ### 02 */
.b02_slide_in {
overflow: hidden;
border: #000000 solid 1px;
}
.b02_slide_in div {
position: absolute;
text-align: center;
width: 100%;
height: 50px;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
padding: 10px;
}
.b02_slide_in div:nth-child(1) {
color: #000000;
background-color: #ffffff;
}
.b02_slide_in div:nth-child(2) {
background-color: #000000;
transition: top 0.1s ease;
-webkit-transition: top 0.1s ease;
-moz-transition: top 0.1s ease;
top: -50px;
}
.b02_slide_in div:nth-child(3) {
color: #ffffff;
transition: opacity 0.1s ease;
-webkit-transition: opacity 0.1s ease;
-moz-transition: opacity 0.1s ease;
opacity: 0;
}
.b02_slide_in:hover div:nth-child(2) {
top: 0px;
transition: top 0.1s ease;
-webkit-transition: top 0.1s ease;
-moz-transition: top 0.1s ease;
}
.b02_slide_in:hover div:nth-child(3) {
opacity: 1;
transition: opacity 0.1s ease;
-webkit-transition: opacity 0.1s ease;
-moz-transition: opacity 0.1s ease;
}
/* ### ### ### 03 */
.b03_skewed_slide_in {
overflow: hidden;
border: #000000 solid 1px;
}
.b03_skewed_slide_in div {
position: absolute;
text-align: center;
width: 100%;
height: 50px;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
padding: 10px;
}
.b03_skewed_slide_in div:nth-child(1) {
color: #000000;
background-color: #ffffff;
}
.b03_skewed_slide_in div:nth-child(2) {
background-color: #000000;
width: 230px;
transition: all 0.2s ease;
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
transform: translate(-250px, 0px) skewX(-30deg);
-webkit-transform: translate(-250px, 0px) skewX(-30deg);
-moz-transform: translate(-250px, 0px) skewX(-30deg);
}
.b03_skewed_slide_in div:nth-child(3) {
color: #ffffff;
left: -200px;
transition: left 0.2s ease;
-webkit-transition: left 0.2s ease;
-moz-transition: left 0.2s ease;
}
.b03_skewed_slide_in:hover div:nth-child(2) {
transition: all 0.5s ease;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
transform: translate(-15px, 0px) skewX(-30deg);
-webkit-transform: translate(-15px, 0px) skewX(-30deg);
-moz-transform: translate(-15px, 0px) skewX(-30deg);
}
.b03_skewed_slide_in:hover div:nth-child(3) {
left: 0px;
transition: left 0.30000000000000004s ease;
-webkit-transition: left 0.30000000000000004s ease;
-moz-transition: left 0.30000000000000004s ease;
}
/* ### ### ### 04 */
.b04_3d_tick {
perspective: 500px;
-webkit-perspective: 500px;
-moz-perspective: 500px;
perspective-origin: center top;
-webkit-perspective-origin: center top;
-moz-perspective-origin: center top;
}
.b04_3d_tick div {
position: absolute;
text-align: center;
width: 100%;
height: 50px;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
padding: 10px;
border: #000000 solid 1px;
}
.b04_3d_tick div:nth-child(1) {
color: #000000;
background-color: #ffffff;
transition: all 0.2s ease;
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
}
.b04_3d_tick div:nth-child(2) {
color: #ffffff;
background-color: #000000;
transform: rotateX(90deg);
-webkit-transform: rotateX(90deg);
-moz-transform: rotateX(90deg);
transition: all 0.2s ease;
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
transform-origin: left top;
-webkit-transform-origin: left top;
-moz-transform-origin: left top;
}
.b04_3d_tick:hover div:nth-child(1) {
transition: all 0.2s ease;
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
background-color: rgba(0, 0, 0, 0.5);
}
.b04_3d_tick:hover div:nth-child(2) {
transition: all 0.2s ease;
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
transform: rotateX(0deg);
-webkit-transform: rotateX(0deg);
-moz-transform: rotateX(0deg);
}
/* ### ### ### 05 */
.b05_3d_roll {
perspective: 500px;
-webkit-perspective: 500px;
-moz-perspective: 500px;
}
.b05_3d_roll div {
position: absolute;
text-align: center;
width: 100%;
height: 50px;
padding: 10px;
border: #000000 solid 1px;
pointer-events: none;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
}
.b05_3d_roll div:nth-child(1) {
color: #000000;
background-color: #000000;
transform: rotateX(90deg);
-webkit-transform: rotateX(90deg);
-moz-transform: rotateX(90deg);
transition: all 0.2s ease;
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
transform-origin: 50% 50% -25px;
-webkit-transform-origin: 50% 50% -25px;
-moz-transform-origin: 50% 50% -25px;
}
.b05_3d_roll div:nth-child(2) {
color: #000000;
background-color: #ffffff;
transform: rotateX(0deg);
-webkit-transform: rotateX(0deg);
-moz-transform: rotateX(0deg);
transition: all 0.2s ease;
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
transform-origin: 50% 50% -25px;
-webkit-transform-origin: 50% 50% -25px;
-moz-transform-origin: 50% 50% -25px;
}
.b05_3d_roll:hover div:nth-child(1) {
color: #ffffff;
transition: all 0.2s ease;
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
transform: rotateX(0deg);
-webkit-transform: rotateX(0deg);
-moz-transform: rotateX(0deg);
}
.b05_3d_roll:hover div:nth-child(2) {
background-color: #000000;
transition: all 0.2s ease;
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
transform: rotateX(-90deg);
-webkit-transform: rotateX(-90deg);
-moz-transform: rotateX(-90deg);
}
/* ### ### ### 06 */
.b06_3d_swap {
perspective: 500px;
-webkit-perspective: 500px;
-moz-perspective: 500px;
transform-style: preserve-3d;
-webkit-transform-style: preserve-3d;
}
<div class="back">
<div class="button_base b02_slide_in">
<div>01_Button</div>
<div></div>
<div>01_Button</div>
</div>
</div>
<div class="back">
<div class="button_base b03_skewed_slide_in">
<div>01_Button</div>
<div></div>
<div>01_Button</div>
</div>
</div>
<div class="back">
<div class="button_base b04_3d_tick">
<div>01_Button</div>
<div>01_Button</div>
</div>
</div>
<div class="back">
<div class="button_base b05_3d_roll">
<div>02_Button</div>
<div>01_Button</div>
</div>
</div>
I want to use these buttons as link for download button. How to use it for setting hyper link in these buttons ? Any help will be appreciated.
You can replace button with an a tag and style it like a button, like this:
01_Button
EDIT: Sorry I didn't see you were using divs. Add you link inside the div, like this:
<div class="button-style">01_Button</div>
<div class="button_base b02_slide_in">
<div>01_Button</div>
<div></div>
<div><a class="link" href="#">01_Button</a></div>
</div>
<style>
.link:hover
{
color:#fff;
text-decoration: none;
}
</style
I am trying to slide up an element on a button click with css property transfrom: translate3d(0,-100px,0); but the element below having relative position is no sliding up with that element leaving some space.
First Container CSS Properties:
.setupContainer {
position: relative;
display: inline-block;
width: 100%;
height: 100px;
text-align: center;
background-color: rgba(23, 29, 97, 0.9);
color: #FFF;
cursor: default;
z-index: 1;
-webkit-transform: translate3d(0,-100px,0);
-moz-transform: translate3d(0,-100px,0);
-ms-transform: translate3d(0,-100px,0);
-o-transform: translate3d(0,-100px,0);
transform: translate3d(0,-100px,0);
-webkit-transition: all 300ms ease-in-out;
-moz-transition: all 300ms ease-in-out;
-ms-transition: all 300ms ease-in-out;
-o-transition: all 300ms ease-in-out;
transition: all 300ms ease-in-out;
}
Second Container Css Properties:
.top_header {
position: relative;
width: 98%;
height: 165px;
background: #FFF;
margin: 0 auto;
float: none;
clear: both;
top: 1%;
text-align: center;
margin-bottom: 3px;
border-bottom: 2px solid #8CC5A7;
}
I'm trying to create a CSS animation that when the user clicks the burger menu it transforms to an x (step 1), then when the user clicks it again it animates back to the burger menu (step 2).
Step 1 works but I don’t know how to reverse the animation.
Thanks for your help!
http://jsfiddle.net/aX6Cf/
HTML
<a id="mobile-menu">
<span></span>
</a>
CSS
#-webkit-keyframes rotate-plus {
from {
-webkit-transform:rotate(0deg);
}
to {
-webkit-transform:rotate(45deg);
}
}
#-webkit-keyframes rotate-minus {
from {
-webkit-transform:rotate(0deg);
}
to {
-webkit-transform:rotate(-45deg);
}
}
#-webkit-keyframes transition-1 {
from {
top: -6;
transition: all .2s ease-out;
}
to {
top: 0;
transition: all .2s ease-out;
}
}
#-webkit-keyframes transition-2 {
from {
bottom: -6;
transition: all .2s ease-out;
}
to {
bottom: 0;
transition: all .2s ease-out;
}
}
body {
margin: 20px;
}
#mobile-menu {
display: block;
position: relative;
cursor: pointer;
width: 30px;
padding: 6px 30px 9px 0;
box-sizing: border-box;
}
#mobile-menu span,
#mobile-menu span:before,
#mobile-menu span:after {
height: 3px;
width: 30px;
background: #000;
display: block;
content: "";
position: absolute;
left: 50%;
margin-left: -15px;
}
#mobile-menu span:before {
top: -6px;
}
#mobile-menu span:after {
bottom: -6px;
}
#mobile-menu.active span {
background-color: transparent;
}
#mobile-menu.active span:before {
-webkit-animation: rotate-plus .05s ease-out .1s forwards,
transition-1 .05s ease-out forwards;
animation: rotate-plus .05s ease-out .1s forwards,
transition-1 .05s ease-out forwards;
}
#mobile-menu.active span:after {
-webkit-animation: rotate-minus .05s ease-out .1s forwards,
transition-2 .05s ease-out forwards;
animation: rotate-minus .05s ease-out .1s forwards,
transition-2 .05s ease-out forwards;
}
jQuery
$("#mobile-menu").click(function(){
$("#mobile-menu").toggleClass("active");
});
I take back what I said in my comment above. Looks like it is possible to do this with plain CSS, after all... The trick is to use transition delays properly.
HTML
<a id="mobile-menu">
<span></span>
</a>
CSS
body {
margin: 20px;
}
#mobile-menu {
display: block;
position: relative;
cursor: pointer;
width: 30px;
padding: 6px 30px 9px 0;
box-sizing: border-box;
}
#mobile-menu span,
#mobile-menu span:before,
#mobile-menu span:after {
height: 3px;
width: 30px;
background: #000;
display: block;
content: "";
position: absolute;
left: 50%;
margin-left: -15px;
}
#mobile-menu span {
transition: background-color .3s ease .3s;
-webkit-transition: background-color .3s ease .3s;
}
#mobile-menu span:before {
top: -6px;
transition: top .2s ease .2s, transform .2s ease;
-webkit-transition: top .2s ease .2s, -webkit-transform .2s ease;
}
#mobile-menu span:after {
bottom: -6px;
transition: bottom .2s ease .2s, transform .2s ease;
-webkit-transition: bottom .2s ease .2s, -webkit-transform .2s ease;
}
#mobile-menu.active span {
background-color: transparent;
transition: background-color .3s ease;
-webkit-transition: background-color .3s ease;
}
#mobile-menu.active span:before {
top: 0;
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
transition: top .2s ease .1s, transform .2s ease .3s;
-webkit-transition: top .2s ease .1s, -webkit-transform .2s ease .3s;
}
#mobile-menu.active span:after {
bottom: 0;
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
transition: bottom .2s ease .1s, transform .2s ease .3s;
-webkit-transition: bottom .2s ease .1s, -webkit-transform .2s ease .3s;
}
jQuery
$(function() {
$("#mobile-menu").click(function(){
$("#mobile-menu").toggleClass("active");
});
})
Online Demo
Check out this JSfiddle which I tweaked a little bit (to much your code) from the original one in this awesome Codepen.
HTML
<a id="mobile-menu" href="#">
<span></span>
</a>
CSS
a#mobile-menu {
display: inline-block;
width:30px;
height:18px;
cursor: pointer;
text-decoration: none;
}
a#mobile-menu span {
position: relative;
display: inline-block;
width: 30px;
height: 3px;
color:#252525;
font:bold 14px/.4 Helvetica;
text-transform: uppercase;
text-indent:-55px;
background: #252525;
transition:all .2s ease-out;
}
a#mobile-menu span::before, a#mobile-menu span::after {
content:'';
width: 30px;
height: 3px;
background: #252525;
position: absolute;
left:0;
transition:all .2s ease-out;
}
a#mobile-menu span::before {
top: -7px;
}
a#mobile-menu span::after {
bottom: -7px;
}
a#mobile-menu.active span {
background: #fff;
}
a#mobile-menu.active span::before {
top:0;
-webkit-transform: rotateZ(45deg);
-moz-transform: rotateZ(45deg);
-ms-transform: rotateZ(45deg);
-o-transform: rotateZ(45deg);
transform: rotateZ(45deg);
}
a#mobile-menu.active span::after {
bottom:0;
-webkit-transform: rotateZ(-45deg);
-moz-transform: rotateZ(-45deg);
-ms-transform: rotateZ(-45deg);
-o-transform: rotateZ(-45deg);
transform: rotateZ(-45deg);
}
a#mobile-menu {
position: absolute;
left:50%;
margin-left:-9px;
top:50%;
margin-top:-9px;
}
jQuery
$('a').click(function() {
$(this).toggleClass('active');
});
As I said all credit goes to this codepen