transform-origin - HTML CSS CSS Animatable Property

HTML CSS examples for CSS Animatable Property:transform-origin

Introduction

In the following code the "club card" image is rotating 180 degree clockwise and its transform-origin is also animating form its initial value "50% 50% 0" to "right center 0", and back to the initial value "right center 0" again up to infinite times.

-webkit- prefix is for Chrome, Safari, Opera.

-moz- prefix is for Firefox.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html lang="en">
 <head>
  <title>Example of CSS3 transform-origin Property Animation</title>
  <style type="text/css">
.container{<!-- w ww . ja v a 2s .com-->
  width: 125px;
    height: 125px;
  margin: 50px;
    perspective: 300px;
    border: 4px solid #a2b058;
    background: #f0f5d8;
}
.container img{
  -webkit-animation: test 4s infinite;  
  animation: test 4s infinite;  
}

@-webkit-keyframes test {
    50% {
        -webkit-transform: rotate3d(0, 1, 0, -180deg); 
        -webkit-transform-origin: right center 0;
    }
}

@keyframes test {
    50% {
        transform: rotate3d(0, 1, 0, -180deg); 
        transform-origin: right center 0;
    }
}
</style>
 </head>
 <body>

  <p> </p>
  <div class="container">
   <img src="https://www.java2s.com/style/demo/Opera.png" alt="Club Card">
  </div>
 </body>
</html>

Related Tutorials