Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
  <style>
    body {
      background: #333;
    }
    div {
      width: 100px;
      height: 100px;
      background: magenta;
      transition: 0.5s;
      animation: 0.5s out forwards;
    }
     
    .foo {
      animation: 0.5s in forwards;
    }
    
    @keyframes in {
      from {
        background: magenta;
        transform: translate(0, 0) rotate(0);
      }
      to {
        background: aqua;
        transform: translate(100px, 100px) rotate(0.5turn);
      }
    }
    
    @keyframes out {
      from {
        background: aqua;
        transform: translate(100px, 100px) rotate(0.5turn);
      }
      to {
        background: magenta;
        transform: translate(0, 0) rotate(0);
      }
    }
  </style>
</head>
<body>
  <div></div>
  <script>
    document.querySelector('div').addEventListener('click', function(){
      this.classList.toggle('foo');
    });
  </script>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers