I want to disable css animation on page load only.
The thing is that this css animation is the menu icon of main navigation menu, but when on subpages (where there also is a submenu present) on click on submenu the main menu animation activates - but i would like it to only start when my main navigation icon is clicked. I provided html, javascript and css involved.
I would appreciate your support in this.
html:
<div class="mcwrap">
<input id="click" name="exit" type="checkbox">
<label for="click"><span class="burger"></span></label>
</div>
javascript:
$('.mcwrap label').on('click', function(){
(!$('#click').prop('checked')) ? setTimeout(function(){opensLeft()}, 200) : setTimeout(function(){closesLeft()}, 200);
});
function opensLeft() {
$("#sl").addClass('visible')
$("#swipe").addClass('isOpenLeft');
}
function closesLeft() {
$("#sl").removeClass('visible')
$("#swipe").removeClass('isOpenLeft');
}
css:
#sl.visible, #sr.visible {
display: block;
}
.mcwrap {
padding-top: 9px;
}
.mcwrap input {
display: none;
}
.mcwrap label {
position: relative;
width: 20px;
height: 30px;
display: block;
cursor: pointer;
background: transparent;
}
/* Exit Icon */
.mcwrap label:before,
.mcwrap input:checked + label:before {
content: '';
position: absolute;
top: 50%;
margin-top: -2px;
width: 30px;
height: 4px;
border-radius: 2px;
background: #fafafa;
}
.mcwrap label:before {
-webkit-animation: animationOneReverse 1s ease forwards;
animation: animationOneReverse 1s ease forwards;
}
#-webkit-keyframes animationOneReverse {
0% {
-webkit-transform: rotate(315deg);
}
25% {
-webkit-transform: rotate(360deg);
}
50%,
100% {
-webkit-transform: rotate(0deg);
}
}
#keyframes animationOneReverse {
0% {
transform: rotate(315deg);
}
25% {
transform: rotate(360deg);
}
50%,
100% {
transform: rotate(0deg);
}
}
.mcwrap input:checked + label:before {
-webkit-animation: animationOne 1s ease forwards;
animation: animationOne 1s ease forwards;
}
#-webkit-keyframes animationOne {
0%,
50% {
-webkit-transform: rotate(0deg);
}
75% {
-webkit-transform: rotate(360deg);
}
100% {
-webkit-transform: rotate(315deg);
}
}
#keyframes animationOne {
0%,
50% {
transform: rotate(0deg);
}
75% {
transform: rotate(360deg);
}
100% {
transform: rotate(315deg);
}
}
.mcwrap label:after,
.mcwrap input:checked + label:after {
content: '';
position: absolute;
top: 50%;
margin-top: -2px;
width: 30px;
height: 4px;
border-radius: 2px;
background: #fafafa;
}
.mcwrap label:after {
-webkit-animation: animationTwoReverse 1s ease forwards;
animation: animationTwoReverse 1 s ease forwards;
}
#-webkit-keyframes animationTwoReverse {
0% {
-webkit-transform: rotate(405deg);
}
25% {
-webkit-transform: rotate(450deg);
}
50%,
100% {
-webkit-transform: rotate(0deg);
}
}
#keyframes animationTwoReverse {
0% {
transform: rotate(405deg);
}
25% {
transform: rotate(450deg);
}
50%,
100% {
transform: rotate(0deg);
}
}
.mcwrap input:checked + label:after {
-webkit-animation: animationTwo 1s ease forwards;
animation: animationTwo 1s ease forwards;
}
#-webkit-keyframes animationTwo {
0%,
50% {
-webkit-transform: rotate(0deg);
}
75% {
-webkit-transform: rotate(450deg);
}
100% {
-webkit-transform: rotate(405deg);
}
}
#keyframes animationTwo {
0%,
50% {
transform: rotate(0deg);
}
75% {
transform: rotate(450deg);
}
100% {
transform: rotate(405deg);
}
}
/* Burger Icon */
.mcwrap label .burger:before {
content: '';
position: absolute;
top: 4px;
width: 30px;
height: 4px;
border-radius: 2px;
background: #fafafa;
-webkit-animation: animationBurgerTopReverse 1s ease forwards;
animation: animationBurgerTopReverse 1s ease forwards;
}
#-webkit-keyframes animationBurgerTopReverse {
0%,
50% {
-webkit-transform: translateY(12px);
opacity: 0;
}
51% {
-webkit-transform: translateY(12px);
opacity: 1;
}
100% {
-webkit-transform: translateY(0px);
opacity: 1;
}
}
#keyframes animationBurgerTopReverse {
0%,
50% {
transform: translateY(12px);
opacity: 0;
}
51% {
transform: translateY(12px);
opacity: 1;
}
100% {
transform: translateY(0px);
opacity: 1;
}
}
.mcwrap input:checked + label .burger:before {
-webkit-animation: animationBurgerTop 1s ease forwards;
animation: animationBurgerTop 1s ease forwards;
}
#-webkit-keyframes animationBurgerTop {
0% {
-webkit-transform: translateY(0px);
opacity: 1;
}
50% {
-webkit-transform: translateY(12px);
opacity: 1;
}
51%,
100% {
-webkit-transform: translateY(12px);
opacity: 0;
}
}
#keyframes animationBurgerTop {
0% {
transform: translateY(0px);
opacity: 1;
}
50% {
transform: translateY(12px);
opacity: 1;
}
51%,
100% {
transform: translateY(12px);
opacity: 0;
}
}
.mcwrap label .burger:after {
content: '';
position: absolute;
bottom: 4px;
width: 30px;
height: 4px;
border-radius: 2px;
background: #fafafa;
-webkit-animation: animationBurgerBottomReverse 1s ease forwards;
animation: animationBurgerBottomReverse 1s ease forwards;
}
#-webkit-keyframes animationBurgerBottomReverse {
0%,
50% {
-webkit-transform: translateY(-12px);
opacity: 0;
}
51% {
-webkit-transform: translateY(-12px);
opacity: 1;
}
100% {
-webkit-transform: translateY(0px);
opacity: 1;
}
}
#keyframes animationBurgerBottomReverse {
0%,
50% {
transform: translateY(-12px);
opacity: 0;
}
51% {
transform: translateY(-12px);
opacity: 1;
}
100% {
transform: translateY(0px);
opacity: 1;
}
}
.mcwrap input:checked + label .burger:after {
-webkit-animation: animationBurgerBottom 1s ease forwards;
animation: animationBurgerBottom 1s ease forwards;
}
#-webkit-keyframes animationBurgerBottom {
0% {
-webkit-transform: translateY(0px);
opacity: 1;
}
50% {
-webkit-transform: translateY(-12px);
opacity: 1;
}
51%,
100% {
-webkit-transform: translateY(-12px);
opacity: 0;
}
}
#keyframes animationBurgerBottom {
0% {
transform: translateY(0px);
opacity: 1;
}
50% {
transform: translateY(-12px);
opacity: 1;
}
51%,
100% {
transform: translateY(-12px);
opacity: 0;
}
}
Add in JS a class when document is loaded:
$(window).on('load', function(){
$('body').addClass('loaded')
});
Then in CSS:
.loaded .mcwrap label:before {
-webkit-animation: animationOneReverse 1s ease forwards;
animation: animationOneReverse 1s ease forwards;
}
Repeat this example for every animation that need the load event
Related
In below code, the animation plays fine for both initialization and for hover, however when I stop hovering the initial animation is re-played. How do I stop this behaviour? Thanks,
Rik
.logoImage2{
width:100%;
-webkit-filter: drop-shadow(12px 8px 4px #222);
filter: drop-shadow(12px 8px 3px #222);
padding-bottom:2rem;
animation: moveInTopRight 5s ease-out;
}
.logoImage2:hover{
animation: spinY 5s ease-in-out;
}
#keyframes moveInTopRight {
0% {
opacity: 0;
transform: translate3d(50rem,-50rem,50rem) rotateZ(0);
}
80% {
opacity: .5;
transform: translate3d(5rem,5rem,5rem) rotateZ(180deg);
}
100% {
opacity: 1;
transform: translate3d(0,0,0) rotateZ(360deg);
}
}
#keyframes spinY {
0% {
transform:rotateY(0);
}
50% {
transform: rotateY(180deg);
}
100% {
transform: rotateY(360deg);
}
}
You should use them within the same animation to avoid the first one to restart:
.box{
width: 200px;
height:200px;
background:red;
margin:50px;
animation: moveInTopRight 5s ease-out;
}
.box:hover {
animation:moveInTopRight 5s ease-out, spinY 5s ease-in-out;
}
#keyframes moveInTopRight {
0% {
opacity: 0;
transform: translate3d(50rem, -50rem, 50rem) rotateZ(0);
}
80% {
opacity: .5;
transform: translate3d(5rem, 5rem, 5rem) rotateZ(180deg);
}
100% {
opacity: 1;
transform: translate3d(0, 0, 0) rotateZ(360deg);
}
}
#keyframes spinY {
0% {
transform: rotateY(0);
}
50% {
transform: rotateY(180deg);
}
100% {
transform: rotateY(360deg);
}
}
<div class="box">
</div>
And for this particular case you can replace the second animation with a transition:
.box{
width: 200px;
height:200px;
background:red;
margin:50px;
animation: moveInTopRight 5s ease-out;
transition:0s;
}
.box:hover {
transform: rotateY(360deg);
transition:transform 5s ease-in;
}
#keyframes moveInTopRight {
0% {
opacity: 0;
transform: translate3d(50rem, -50rem, 50rem) rotateZ(0);
}
80% {
opacity: .5;
transform: translate3d(5rem, 5rem, 5rem) rotateZ(180deg);
}
100% {
opacity: 1;
transform: translate3d(0, 0, 0) rotateZ(360deg);
}
}
<div class="box">
</div>
I have tried to make an animated arrow like like the one in this site. A demo of my code attempt is available here. But the animation is not working in-line with the animation in the site.
My Code :
.animated-arrow-1 {
-webkit-animation: arrow1 3s infinite ease-out;
animation: arrow1 3s infinite ease-out;
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0);
opacity: 0
}
.animated-arrow-2 {
-webkit-animation: arrow2 3s infinite ease-in;
animation: arrow2 3s infinite ease-in;
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
opacity: 1
}
#-webkit-keyframes arrow1 {
0% {
opacity: 0;
-webkit-transform: translate(0,0);
transform: translate(0,0)
}
90% {
opacity: 0;
-webkit-transform: translate(0,0);
transform: translate(0,0)
}
100% {
opacity: 1;
-webkit-transform: translate(0,36px);
transform: translate(0,36px)
}
}
#keyframes arrow1 {
0% {
opacity: 0;
-webkit-transform: translate(0,0);
-ms-transform: translate(0,0);
transform: translate(0,0)
}
90% {
opacity: 0;
-webkit-transform: translate(0,0);
-ms-transform: translate(0,0);
transform: translate(0,0)
}
100% {
opacity: 1;
-webkit-transform: translate(0,36px);
-ms-transform: translate(0,36px);
transform: translate(0,36px)
}
}
#-webkit-keyframes arrow2 {
0% {
opacity: 1;
-webkit-transform: translate(0,0);
transform: translate(0,0)
}
90% {
opacity: 1;
-webkit-transform: translate(0,0);
transform: translate(0,0)
}
100% {
opacity: 0;
-webkit-transform: translate(0,36px);
transform: translate(0,36px)
}
}
#keyframes arrow2 {
0% {
opacity: 1;
-webkit-transform: translate(0,0);
-ms-transform: translate(0,0);
transform: translate(0,0)
}
90% {
opacity: 1;
-webkit-transform: translate(0,0);
-ms-transform: translate(0,0);
transform: translate(0,0)
}
100% {
opacity: 0;
-webkit-transform: translate(0,36px);
-ms-transform: translate(0,36px);
transform: translate(0,36px)
}
}
Could you please anybody tell me what I missed here?
You were reasonably close to achieving the required animation. In your code, there was only one movement from 0px to 36px for both the arrows but what was actually needed is a two stage animation with different keyframe settings for the two arrows. One arrow should start invisible at 0px, fade-in to 50px, stay there and then fade-out to 100px whereas the other arrow should start visible at 50px, fade-out to 100px, immediately go to 0px and then fade-in at 50px.
.icon {
position: relative;
}
.icon img {
position: absolute;
margin: auto;
display: block;
}
.animated-arrow-1 {
animation: arrow1 3s infinite linear;
opacity: 0
}
.animated-arrow-2 {
animation: arrow2 3s infinite linear;
opacity: 1;
}
#keyframes arrow1 {
0%, 10% {
opacity: 0;
transform: translate(0, 0px);
}
50%,
60% {
opacity: 1;
transform: translate(0, 50px)
}
100% {
opacity: 0;
transform: translate(0, 100px)
}
}
#keyframes arrow2 {
0%, 10% {
opacity: 1;
transform: translate(0, 50px);
}
50%,
60% {
opacity: 0;
transform: translate(0, 100px)
}
61% {
opacity: 0;
transform: translate(0, 0);
}
100% {
opacity: 1;
transform: translate(0, 50px)
}
}
body {
background: #000;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
<div class="icon">
<img src="http://s12.postimg.org/ibsmfp6w9/Down_Arrow.png" class="animated-arrow-1" />
<img src="http://s12.postimg.org/ibsmfp6w9/Down_Arrow.png" class="animated-arrow-2" />
</div>
I've added rotating text w/ CSS animation. I want the animation to go through 1 cycle and freeze on the last frame. With my current code, the animation does one cycle and ends on a blank frame. Any suggestions on how to correct this?
body {} .rw-wrapper {
width: 80%;
position: relative;
margin: 110px auto 0 auto;
font-family: 'Bree Serif';
padding: 10px;
}
.rw-sentence {
margin: 0;
text-align: left;
text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.8);
}
.rw-sentence span {
color: #444;
font-size: 200%;
font-weight: normal;
}
.rw-words {
display: inline;
text-indent: 10px;
}
.rw-words-1 span {
position: absolute;
opacity: 0;
overflow: hidden;
color: #6b969d;
-webkit-animation: rotateWord 8s 1 forwards;
-ms-animation: rotateWord 8s 1 forwards;
animation: rotateWord 8s 1 forwards;
}
.rw-words-1 span:nth-child(2) {
-webkit-animation-delay: 2s;
-ms-animation-delay: 2s;
animation-delay: 2s;
color: #6b889d;
}
.rw-words-1 span:nth-child(3) {
-webkit-animation-delay: 4s;
-ms-animation-delay: 4s;
animation-delay: 4s;
color: #6b739d;
}
.rw-words-1 span:nth-child(4) {
-webkit-animation-delay: 6s;
-ms-animation-delay: 6s;
animation-delay: 6s;
color: #7a6b9d;
}
#-webkit-keyframes rotateWord {
0% {
opacity: 0;
}
2% {
opacity: 0;
-webkit-transform: translateY(-30px);
}
5% {
opacity: 1;
-webkit-transform: translateY(0px);
}
17% {
opacity: 1;
-webkit-transform: translateY(0px);
}
20% {
opacity: 0;
-webkit-transform: translateY(30px);
}
80% {
opacity: 0;
}
100% {
opacity: 0;
}
}
#-ms-keyframes rotateWord {
0% {
opacity: 0;
}
2% {
opacity: 0;
-ms-transform: translateY(-30px);
}
5% {
opacity: 1;
-ms-transform: translateY(0px);
}
17% {
opacity: 1;
-ms-transform: translateY(0px);
}
20% {
opacity: 0;
-ms-transform: translateY(30px);
}
80% {
opacity: 0;
}
100% {
opacity: 0;
}
}
#keyframes rotateWord {
0% {
opacity: 0;
}
2% {
opacity: 0;
-webkit-transform: translateY(-30px);
transform: translateY(-30px);
}
5% {
opacity: 1;
-webkit-transform: translateY(0px);
transform: translateY(0px);
}
17% {
opacity: 1;
-webkit-transform: translateY(0px);
transform: translateY(0px);
}
20% {
opacity: 0;
-webkit-transform: translateY(30px);
transform: translateY(30px);
}
80% {
opacity: 0;
}
100% {
opacity: 0;
}
}
#media screen and (max-width: 768px) {
.rw-sentence {
font-size: 18px;
}
}
#media screen and (max-width: 320px) {
.rw-sentence {
font-size: 9px;
}
}
<section class="rw-wrapper">
<h2 class="rw-sentence">
<span>Test</span>
<div class="rw-words rw-words-1">
<span>one</span>
<span>two</span>
<span>three</span>
<span>four</span>
</div>
</h2>
</section>
You keyframe at 100% has opacity zero. You can write a separate animation for the last work and use that instead.
Like this (I didn't add vendor-specific keyframes, just #keyframes rotateLastWord, but you can add them as well):
body {} .rw-wrapper {
width: 80%;
position: relative;
margin: 110px auto 0 auto;
font-family: 'Bree Serif';
padding: 10px;
}
.rw-sentence {
margin: 0;
text-align: left;
text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.8);
}
.rw-sentence span {
color: #444;
font-size: 200%;
font-weight: normal;
}
.rw-words {
display: inline;
text-indent: 10px;
}
.rw-words-1 span {
position: absolute;
opacity: 0;
overflow: hidden;
color: #6b969d;
-webkit-animation: rotateWord 8s 1 forwards;
-ms-animation: rotateWord 8s 1 forwards;
animation: rotateWord 8s 1 forwards;
}
.rw-words-1 span:nth-child(2) {
-webkit-animation-delay: 2s;
-ms-animation-delay: 2s;
animation-delay: 2s;
color: #6b889d;
}
.rw-words-1 span:nth-child(3) {
-webkit-animation-delay: 4s;
-ms-animation-delay: 4s;
animation-delay: 4s;
color: #6b739d;
}
#-webkit-keyframes rotateWord {
0% {
opacity: 0;
}
2% {
opacity: 0;
-webkit-transform: translateY(-30px);
}
5% {
opacity: 1;
-webkit-transform: translateY(0px);
}
17% {
opacity: 1;
-webkit-transform: translateY(0px);
}
20% {
opacity: 0;
-webkit-transform: translateY(30px);
}
80% {
opacity: 0;
}
100% {
opacity: 0;
}
}
#-ms-keyframes rotateWord {
0% {
opacity: 0;
}
2% {
opacity: 0;
-ms-transform: translateY(-30px);
}
5% {
opacity: 1;
-ms-transform: translateY(0px);
}
17% {
opacity: 1;
-ms-transform: translateY(0px);
}
20% {
opacity: 0;
-ms-transform: translateY(30px);
}
80% {
opacity: 0;
}
100% {
opacity: 0;
}
}
#keyframes rotateWord {
0% {
opacity: 0;
}
2% {
opacity: 0;
-webkit-transform: translateY(-30px);
transform: translateY(-30px);
}
5% {
opacity: 1;
-webkit-transform: translateY(0px);
transform: translateY(0px);
}
17% {
opacity: 1;
-webkit-transform: translateY(0px);
transform: translateY(0px);
}
20% {
opacity: 0;
-webkit-transform: translateY(30px);
transform: translateY(30px);
}
80% {
opacity: 0;
}
100% {
opacity: 0;
}
}
#media screen and (max-width: 768px) {
.rw-sentence {
font-size: 18px;
}
}
#media screen and (max-width: 320px) {
.rw-sentence {
font-size: 9px;
}
}
/* stuff below added by Shomz */
.rw-words-1 span#last {
-webkit-animation: rotateLastWord 8s 1 forwards 6s;
-ms-animation: rotateLastWord 8s 1 forwards 6s;
animation: rotateLastWord 8s 1 forwards 6s;
}
#keyframes rotateLastWord {
0% {
opacity: 0;
}
2% {
opacity: 0;
-webkit-transform: translateY(-30px);
transform: translateY(-30px);
}
5% {
opacity: 1;
-webkit-transform: translateY(0px);
transform: translateY(0px);
}
17% {
opacity: 1;
-webkit-transform: translateY(0px);
transform: translateY(0px);
}
100% {opacity: 1}
}
<section class="rw-wrapper">
<h2 class="rw-sentence">
<span>Test</span>
<div class="rw-words rw-words-1">
<span>one</span>
<span>two</span>
<span>three</span>
<span id="last">four</span>
</div>
</h2>
</section>
I'm trying to get a bouncing mouse animation to work on my website.
The exact same code works on another website, whereas on mine it just doesn't do anything.
Here's the css:
.mouse {
display: block;
margin: 0 auto;
text-align: center;
width: 100%;
font-size: 32px;
color: #fff;
z-index:9999;
position: absolute;
color: #e8e8e8;;
bottom: 240px;
}
.mouse i {
-webkit-animation: todown 1.2s infinite linear;
transition: all 0.3s ease-in-out;
}
The HTML:
<a href="#x11" class="mouse">
<i class="fa fa-angle-double-down icon-option"></i>
</a>
On this website you can see the scrolldown icon I'm trying to create: http://noxxar.com/demo/uralco/
If you want to use CSS animations you need to define #keyframes.
Luckily the CSS on the theme you linked isn't minified or anything, so you can just copy/paste the parts you want to recreate.
Since Firefox 15 the -moz vendor prefix isn't needed but Chrome and other Webkit Browser still need -webkit-animation: http://caniuse.com/#feat=css-animation
CSS:
#to-slider-scrollto i {
-webkit-animation: todown 1.2s infinite linear;
animation: todown 1.2s infinite linear;
}
#to-slider-scrollto i:hover {
-webkit-animation: none;
animation: none;
}
#-webkit-keyframes todown {
0% {
-webkit-transform: translateY(-15px);
opacity: 0;
}
10% {
-webkit-transform: translateY(-15px);
opacity: 0;
}
50% {
-webkit-transform: translateY(0);
opacity: 1;
}
90% {
-webkit-transform: translateY(15px);
opacity: 0;
}
100% {
-webkit-transform: translateY(15px);
opacity: 0;
}
}
#keyframes todown {
0% {
transform: translateY(-15px);
opacity: 0;
}
10% {
transform: translateY(-15px);
opacity: 0;
}
50% {
transform: translateY(0);
opacity: 1;
}
90% {
transform: translateY(15px);
opacity: 0;
}
100% {
transform: translateY(15px);
opacity: 0;
}
}
Working codepen demo with only the needed CSS
Check out cross browser compatibility
.mouse i {
-webkit-animation: todown 1.2s linear infinite;
animation: todown 1.2s linear infinite;
}
#-webkit-keyframes todown {
0% {
-webkit-transform: translateY(0px);
transform: translateY(0px);
}
50% {
-webkit-transform: translateY(5px);
transform: translateY(5px);
}
}
#keyframes todown {
0% {
-webkit-transform: translateY(0px);
transform: translateY(0px);
}
50% {
-webkit-transform: translateY(5px);
transform: translateY(5px);
}
}
I am currently working on sidebar navigation for a mobile site and I am trying to include the below animation for the main menu button.
This works well on different browsers except for mobile devices running iOS - Safari and Android - Android Browser. What am I missing? Thanks.
http://jsfiddle.net/wvck5xnL/
HTML
<div class="mainBtn">
<input id="mainmenuBtn" name="exit" type="checkbox" />
<label for="mainmenuBtn"><span class="burger"></span></label>
</div>
CSS
body {
padding:0;
margin:0;
overflow: hidden;
background:white;
}
/* burger icon animation */
.mainBtn{
display: block;
width: 40px;
padding-left: 10px;
text-align: left;
}
.mainBtn input {
display: none;
}
.mainBtn label {
position: relative;
width: 48px;
height: 57px;
display: block;
cursor: pointer;
background: transparent;
}
/* Exit Icon */
.mainBtn label:before,
.mainBtn input:checked + label:before {
content: '';
position: absolute;
top: 50%;
margin-top: -2px;
width: 30px;
height: 4px;
border-radius: 2px;
background: black;
}
.mainBtn label:before {
-webkit-animation: animationOneReverse 1s ease forwards;
-moz-animation: animationOneReverse 1s ease forwards;
-o-animation: animationOneReverse 1s ease forwards;
-ms-animation: animationOneReverse 1s ease forwards;
animation: animationOneReverse 1s ease forwards;
}
#-webkit-keyframes animationOneReverse {
0% { -webkit-transform: rotate(315deg); }
50%, 100% { -webkit-transform: rotate(0deg); }
}
#-moz-keyframes animationOneReverse {
0% { -moz-transform: rotate(315deg); }
50%, 100% { -moz-transform: rotate(0deg); }
}
#-o-keyframes animationOneReverse {
0% { -o-transform: rotate(315deg); }
50%, 100% { -o-transform: rotate(0deg); }
}
#-ms-keyframes animationOneReverse {
0% { -ms-transform: rotate(315deg); }
50%, 100% { -ms-transform: rotate(0deg); }
}
#keyframes animationOneReverse {
0% { transform: rotate(315deg); }
50%, 100% { transform: rotate(0deg); }
}
.mainBtn input:checked + label:before {
-webkit-animation: animationOne 1s ease forwards;
-moz-animation: animationOne 1s ease forwards;
-o-animation: animationOne 1s ease forwards;
-ms-animation: animationOne 1s ease forwards;
animation: animationOne 1s ease forwards;
}
#-webkit-keyframes animationOne {
0%, 50% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(315deg); }
}
#-moz-keyframes animationOne {
0% { -moz-transform: rotate(0deg); }
50%, 100% { -moz-transform: rotate(315deg); }
}
#-o-keyframes animationOne {
0% { -o-transform: rotate(0deg); }
50%, 100% { -o-transform: rotate(315deg); }
}
#-ms-keyframes animationOne {
0% { -ms-transform: rotate(0deg); }
50%, 100% { -ms-transform: rotate(315deg); }
}
#keyframes animationOne {
0%, 50% { transform: rotate(0deg); }
100% { transform: rotate(315deg); }
}
.mainBtn label:after,
.mainBtn input:checked + label:after {
content: '';
position: absolute;
top: 50%;
margin-top: -2px;
width: 30px;
height: 4px;
border-radius: 2px;
background: black;
}
.mainBtn label:after {
-webkit-animation: animationTwoReverse 1s ease forwards;
-moz-animation: animationTwoReverse 1s ease forwards;
-o-animation: animationTwoReverse 1s ease forwards;
-ms-animation: animationTwoReverse 1s ease forwards;
animation: animationTwoReverse 1s ease forwards;
}
#-webkit-keyframes animationTwoReverse {
0% { -webkit-transform: rotate(405deg); }
50%, 100% { -webkit-transform: rotate(0deg); }
}
#-moz-keyframes animationTwoReverse {
0% { -moz-transform: rotate(405deg); }
50%, 100% { -moz-transform: rotate(0deg); }
}
#-o-keyframes animationTwoReverse {
0% { -o-transform: rotate(405deg); }
50%, 100% { -o-transform: rotate(0deg); }
}
#-ms-keyframes animationTwoReverse {
0% { -ms-transform: rotate(405deg); }
50%, 100% { -ms-transform: rotate(0deg); }
}
#keyframes animationTwoReverse {
0% { transform: rotate(405deg); }
50%, 100% { transform: rotate(0deg); }
}
.mainBtn input:checked + label:after {
-webkit-animation: animationTwo 1s ease forwards;
-moz-animation: animationTwo 1s ease forwards;
-o-animation: animationTwo 1s ease forwards;
-ms-animation: animationTwo 1s ease forwards;
animation: animationTwo 1s ease forwards;
}
#-webkit-keyframes animationTwo {
0%, 50% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(405deg); }
}
#-moz-keyframes animationTwo {
0% { -moz-transform: rotate(0deg); }
50%, 100% { -moz-transform: rotate(405deg); }
}
#-o-keyframes animationTwo {
0% { -o-transform: rotate(0deg); }
50%, 100% { -o-transform: rotate(405deg); }
}
#-ms-keyframes animationTwo {
0% { -ms-transform: rotate(0deg); }
50%, 100% { -ms-transform: rotate(405deg); }
}
#keyframes animationTwo {
0%, 50% { transform: rotate(0deg); }
100% { transform: rotate(405deg); }
}
/* Burger Icon */
.mainBtn label .burger:before {
content: '';
position: absolute;
top: 17px;
width: 30px;
height: 4px;
border-radius: 2px;
background: black;
-webkit-animation: animationBurgerTopReverse 1s ease forwards;
-moz-animation: animationBurgerTopReverse 1s ease forwards;
-o-animation: animationBurgerTopReverse 1s ease forwards;
-ms-animation: animationBurgerTopReverse 1s ease forwards;
animation: animationBurgerTopReverse 1s ease forwards;
}
#-webkit-keyframes animationBurgerTopReverse {
0%, 50% { -webkit-transform: translateY(12px); opacity: 0; }
51% { -webkit-transform: translateY(12px); opacity: 1; }
100% { -webkit-transform: translateY(0px); opacity: 1; }
}
#-moz-keyframes animationBurgerTopReverse {
0%, 50% { -moz-transform: translateY(12px); opacity: 0; }
51% { -moz-transform: translateY(12px); opacity: 1; }
100% { -moz-transform: translateY(0px); opacity: 1; }
}
#-o-keyframes animationBurgerTopReverse {
0%, 50% { -o-transform: translateY(12px); opacity: 0; }
51% { -o-transform: translateY(12px); opacity: 1; }
100% { -o-transform: translateY(0px); opacity: 1; }
}
#-ms-keyframes animationBurgerTopReverse {
0%, 50% { -ms-transform: translateY(12px); opacity: 0; }
51% { -ms-transform: translateY(12px); opacity: 1; }
100% { -ms-transform: translateY(0px); opacity: 1; }
}
#keyframes animationBurgerTopReverse {
0%, 50% { transform: translateY(12px); opacity: 0; }
51% { transform: translateY(12px); opacity: 1; }
100% { transform: translateY(0px); opacity: 1; }
}
.mainBtn input:checked + label .burger:before {
-webkit-animation: animationBurgerTop 1s ease forwards;
-moz-animation: animationBurgerTop 1s ease forwards;
-o-animation: animationBurgerTop 1s ease forwards;
-ms-animation: animationBurgerTop 1s ease forwards;
animation: animationBurgerTop 1s ease forwards;
}
#-webkit-keyframes animationBurgerTop {
0% { -webkit-transform: translateY(0px); opacity: 1; }
50% { -webkit-transform: translateY(12px); opacity: 1; }
51%, 100% { -webkit-transform: translateY(12px); opacity: 0; }
}
#-moz-keyframes animationBurgerTop {
0% { -moz-transform: translateY(0px); opacity: 1; }
50% { -moz-transform: translateY(12px); opacity: 1; }
51%, 100% { -moz-transform: translateY(12px); opacity: 0; }
}
#-o-keyframes animationBurgerTop {
0% { -o-transform: translateY(0px); opacity: 1; }
50% { -o-transform: translateY(12px); opacity: 1; }
51%, 100% { -o-transform: translateY(12px); opacity: 0; }
}
#-ms-keyframes animationBurgerTop {
0% { -ms-transform: translateY(0px); opacity: 1; }
50% { -ms-transform: translateY(12px); opacity: 1; }
51%, 100% { -ms-transform: translateY(12px); opacity: 0; }
}
#keyframes animationBurgerTop {
0% { transform: translateY(0px); opacity: 1; }
50% { transform: translateY(12px); opacity: 1; }
51%, 100% { transform: translateY(12px); opacity: 0; }
}
.mainBtn label .burger:after {
content: '';
position: absolute;
bottom: 16px;
width: 30px;
height: 4px;
border-radius: 2px;
background: black;
-webkit-animation: animationBurgerBottomReverse 1s ease forwards;
-moz-animation: animationBurgerBottomReverse 1s ease forwards;
-o-animation: animationBurgerBottomReverse 1s ease forwards;
-ms-animation: animationBurgerBottomReverse 1s ease forwards;
animation: animationBurgerBottomReverse 1s ease forwards;
}
#-webkit-keyframes animationBurgerBottomReverse {
0%, 50% { -webkit-transform: translateY(-12px); opacity: 0; }
51% { -webkit-transform: translateY(-12px); opacity: 1; }
100% { -webkit-transform: translateY(0px); opacity: 1; }
}
#-moz-keyframes animationBurgerBottomReverse {
0%, 50% { -moz-transform: translateY(-12px); opacity: 0; }
51% { -moz-transform: translateY(-12px); opacity: 1; }
100% { -moz-transform: translateY(0px); opacity: 1; }
}
#-o-keyframes animationBurgerBottomReverse {
0%, 50% { -o-transform: translateY(-12px); opacity: 0; }
51% { -o-transform: translateY(-12px); opacity: 1; }
100% { -o-transform: translateY(0px); opacity: 1; }
}
#-ms-keyframes animationBurgerBottomReverse {
0%, 50% { -ms-transform: translateY(-12px); opacity: 0; }
51% { -ms-transform: translateY(-12px); opacity: 1; }
100% { -ms-transform: translateY(0px); opacity: 1; }
}
#keyframes animationBurgerBottomReverse {
0%, 50% { transform: translateY(-12px); opacity: 0; }
51% { transform: translateY(-12px); opacity: 1; }
100% { transform: translateY(0px); opacity: 1; }
}
.mainBtn input:checked + label .burger:after {
-webkit-animation: animationBurgerBottom 1s ease forwards;
-moz-animation: animationBurgerBottom 1s ease forwards;
-o-animation: animationBurgerBottom 1s ease forwards;
-ms-animation: animationBurgerBottom 1s ease forwards;
animation: animationBurgerBottom 1s ease forwards;
}
#-webkit-keyframes animationBurgerBottom {
0% { -webkit-transform: translateY(0px); opacity: 1; }
50% { -webkit-transform: translateY(-12px); opacity: 1; }
51%, 100% { -webkit-transform: translateY(-12px); opacity: 0; }
}
#-moz-keyframes animationBurgerBottom {
0% { -moz-transform: translateY(0px); opacity: 1; }
50% { -moz-transform: translateY(-12px); opacity: 1; }
51%, 100% { -moz-transform: translateY(-12px); opacity: 0; }
}
#-o-keyframes animationBurgerBottom {
0% { -o-transform: translateY(0px); opacity: 1; }
50% { -o-transform: translateY(-12px); opacity: 1; }
51%, 100% { -o-transform: translateY(-12px); opacity: 0; }
}
#-ms-keyframes animationBurgerBottom {
0% { -ms-transform: translateY(0px); opacity: 1; }
50% { -ms-transform: translateY(-12px); opacity: 1; }
51%, 100% { -ms-transform: translateY(-12px); opacity: 0; }
}
#keyframes animationBurgerBottom {
0% { transform: translateY(0px); opacity: 1; }
50% { transform: translateY(-12px); opacity: 1; }
51%, 100% { transform: translateY(-12px); opacity: 0; }
}
Hi I tried your fiddle and it worked on my mobile, which is iphone5s.
But anyway, as far as I've known, when you want to use keyframes-translate for an element. The element has to be displayed block, or it has to be wrapped by a div, which default is displayed block too.
a {
background:orange;
}
div {
-webkit-animation: move 5s infinite;
}
#-webkit-keyframes move {
0% { -webkit-transform: translate(20px); }
100% { -webkit-transform: translate(500px); }
}
<div class="wrapper">Test</div>
I'm thinking maybe translate doesn't support some elements completely. For instance, when you want to translate a tag element, you have to set the element display: block.
However, when you want to apply translate on a div element, if you set the css on the div element display:inline-block, the translate will still work on that div.
So maybe try to set the elements that you'd like to move display:block.