Question

I have the following two codes

.button:hover {
   -webkit-transition: all 0.3s ease-out;  /* Chrome 1-25, Safari 3.2+ */
      -moz-transition: all 0.3s ease-out;  /* Firefox 4-15 */
        -o-transition: all 0.3s ease-out;  /* Opera 10.50–12.00 */
           transition: all 0.3s ease-out;  /* Chrome 26, Firefox 16+, IE 10+, Opera 12.10+ */
}

And

@-webkit-keyframes flipInX {
    0% {
        -webkit-transform: perspective(400px) rotateX(90deg);
        opacity: 0;
    }

    40% {
        -webkit-transform: perspective(400px) rotateX(-10deg);
    }

    70% {
        -webkit-transform: perspective(400px) rotateX(10deg);
    }

    100% {
        -webkit-transform: perspective(400px) rotateX(0deg);
        opacity: 1;
    }
}
@-moz-keyframes flipInX {
    0% {
        -moz-transform: perspective(400px) rotateX(90deg);
        opacity: 0;
    }

    40% {
        -moz-transform: perspective(400px) rotateX(-10deg);
    }

    70% {
        -moz-transform: perspective(400px) rotateX(10deg);
    }

    100% {
        -moz-transform: perspective(400px) rotateX(0deg);
        opacity: 1;
    }
}
@-o-keyframes flipInX {
    0% {
        -o-transform: perspective(400px) rotateX(90deg);
        opacity: 0;
    }

    40% {
        -o-transform: perspective(400px) rotateX(-10deg);
    }

    70% {
        -o-transform: perspective(400px) rotateX(10deg);
    }

    100% {
        -o-transform: perspective(400px) rotateX(0deg);
        opacity: 1;
    }
}
@keyframes flipInX {
    0% {
        transform: perspective(400px) rotateX(90deg);
        opacity: 0;
    }

    40% {
        transform: perspective(400px) rotateX(-10deg);
    }

    70% {
        transform: perspective(400px) rotateX(10deg);
    }

    100% {
        transform: perspective(400px) rotateX(0deg);
        opacity: 1;
    }
}

.animated.flipInX {
    -webkit-backface-visibility: visible !important;
    -webkit-animation-name: flipInX;
    -moz-backface-visibility: visible !important;
    -moz-animation-name: flipInX;
    -o-backface-visibility: visible !important;
    -o-animation-name: flipInX;
    backface-visibility: visible !important;
    animation-name: flipInX;
}
.animated {
    -webkit-animation-duration: 1s;
       -moz-animation-duration: 1s;
         -o-animation-duration: 1s;
            animation-duration: 1s;
    -webkit-animation-fill-mode: both;
       -moz-animation-fill-mode: both;
         -o-animation-fill-mode: both;
            animation-fill-mode: both;
}

The first code works perfectly on every browser. It gives the required transition. But when I used the second code, It worked perfectly on Chrome. But does not work on any other browser.

I read other questions here, came across here . As it suggested, I should not use -moz -o -webkit. But that did not work for me.

There was a fiddle on that page too, http://jsfiddle.net/EghZs/ . It only works on my chrome. and not on any other browser.

Is this an issue with my browsers? Or is this a problem with the code?

Was it helpful?

Solution

It looks like you aren't specifying for enough browsers at the @ level, and also in your @-moz block, the transform should just be "transform" instead of "-moz-transform" according to Mozilla's current documentation. (Since older versions of Firefox still use -moz-transform, you may have to get tricky with an @support block to manage older and newer Firefox versions at the same time.)

So essentially, you should be good to go after correcting the -moz-transform, and adding the correct support and prefixes for the other browsers.

I would try (condensed your spacing for brevity):

@-webkit-keyframes flipInX {
  /* same block as you already have */
}

@-moz-keyframes flipInX {
  0% {
    transform: perspective(400px) rotateX(90deg);
    opacity: 0;
  }
  40% { transform: perspective(400px) rotateX(-10deg); }
  70% { transform: perspective(400px) rotateX(10deg); }
  100% { transform: perspective(400px) rotateX(0deg); }
}

@-o-keyframes flipInX {  /* Opera */
  0% {
    -o-transform: perspective(400px) rotateX(90deg);
    opacity: 0;
  }
  40% { -o-transform: perspective(400px) rotateX(-10deg); }
  70% { -o-transform: perspective(400px) rotateX(10deg); }
  100% { -o-transform: perspective(400px) rotateX(0deg); }
}

@keyframes flipInX {
  /* this will cover other browsers that
     support keyframes and transforms */
  0% {
    -ms-transform: perspective(400px) rotateX(90deg);
    transform: perspective(400px) rotateX(90deg);
    opacity: 0;
  }
  40% { 
   -ms-transform: perspective(400px) rotateX(-10deg);
   transform: perspective(400px) rotateX(-10deg); 
  }
  70% { 
    -ms-transform: perspective(400px) rotateX(10deg); 
    transform: perspective(400px) rotateX(10deg);
  }
  100% { 
    -ms-transform: perspective(400px) rotateX(0deg); 
    transform: perspective(400px) rotateX(0deg);
  }
}

Edit: IE will require -ms-transform, so I added that in.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top