Animation How to - Create animation and rotate on X








Question

We would like to know how to create animation and rotate on X.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#First {<!--   w ww .  j a v a 2 s.  c  om-->
    width: 200px;
    height: 50px;
    position: absolute;
    top: 5px;
    color: black;
    text-align: center;
    background-color: yellow;
    -webkit-transform-origin: bottom;
    -webkit-animation: myfirst 1s;
    -webkit-transform: rotateX(90deg);
    -webkit-animation-iteration-count: infinite;
}
@-webkit-keyframes myfirst {
    0% {
        -webkit-transform: rotateX(0deg);
    }
    100% {
        -webkit-transform: rotateX(90deg);
    }
}
#Second {
    width: 200px;
    height: 50px;
    position: absolute;
    top: 5px;
    left: 200px;
    color: black;
    text-align: center;
    background-color: green;
    -webkit-transform-origin: top;
    -webkit-animation: mysecond 1s;
    -webkit-transform: rotateX(0deg);
    -webkit-animation-iteration-count: infinite;
}
@-webkit-keyframes mysecond {
    0% {
        -webkit-transform: rotateX(0deg);
    }
    100% {
        -webkit-transform: rotateX(90deg);
    }
}
</style>
</head>
<body>
  <div id="First">FIRST</div>
  <div id="Second">SECOND</div>
</body>
</html>

The code above is rendered as follows: