Animation How to - Create CSS3 flip animation








Question

We would like to know how to create CSS3 flip animation.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.flipper {<!-- w  w w  .jav  a  2 s  . com-->
    display: block;
    width: 100px;
    height: 100px;
    background: red;
    float: left
}
.green {
    display: block;
    width: 100px;
    height: 100px;
    background: green;
    float: left
}
.flipper:hover  {    
    -webkit-transform: rotatey(180deg);
    backface-visibility: hidden;
    transition: 1s;
  transform-style: preserve-3d;
  position: relative;
}
  </style>
</head>
<body>
    <div class="green"></div>
    <div class="flipper">
       <div class="flip-front">Face</div>
    </div>
</body>
</html>

The code above is rendered as follows: