animation

by rootjang

HTML

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    .box {
      width: 60px;
      height: 60px;
      margin: 10px;
      background: black;
      animation: rotate 1.5s infinite, background 1.5s infinite alternate;
    }

    @keyframes rotate {
      from { transform: perspective(120px) rotateX(0deg) rotateY(0deg); }
      50%  { transform: perspective(120px) rotateX(-180deg) rotateY(0deg); }
      to   { transform: perspective(120px) rotateX(-180deg) rotateY(-180deg); }
    }

    @keyframes background {
      from { background: red; }
      50%  { background: green;}
      to   { background: blue; }
    }
  </style>
</head>
<body>
  <div class="box"></div>
</body>
</html>