title: Why isn't my custom animation working correctly?
body: <p>My custom @keyframes animation is not working the way it should.  </p>
  
  <p>There is no gap between <code>Block 1</code> and <code>Block 2</code> when rotating but there is a small gap between <code>Block 2</code> and <code>Block 3</code>, <code>Block 3</code> and <code>Block 4</code>, and, <code>Block 4</code> and <code>Block 1</code>.</p>
  
  <p>I cant understand why there is a gap between the above listed block or why there is no block between Block 1 and Block 2. What should I do to remove the gaps, I want it to look like a box without the gaps.</p>
  
  <p>Any other advice on the code is also appreciated.
  Below is the code.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.main {
    width: 250px;
    height: 100px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
  
  .main&gt;div {
    width: 250px;
    height: 100px;
    position: absolute;
    text-align: center;
    line-height: 100px;
    color: #fff;
    font-weight: bold;
    font-family: monospace;
    font-size: 2em;
    transition: 1s;
    cursor: pointer;
  }
  
  .child1 {
    background: red;
    transform-origin: bottom;
    animation: animate1 8s infinite;
  }
  
  .child2 {
    background: blue;
    transform-origin: top;
    animation: animate2 8s infinite;
  }
  
  .child3 {
    background: yellow;
    transform-origin: bottom;
    animation: animate3 8s infinite;
  }
  
  .child4 {
    background: green;
    transform-origin: top;
    animation: animate4 8s infinite;
  }
  
  
  /*.main:hover .child1{
   transform: translateY(-100%) rotateX(90deg);
  }
  
  .main:hover .child2{
   transform: translateY(0%) rotateX(0deg);
  }*/
  
  @keyframes animate1 {
    0% {
      transform: translateY(0%) rotateX(0deg);
    }
    25% {
      transform-origin: bottom;
      transform: translateY(-100%) rotateX(90deg);
    }
    50% {
      transform-origin: bottom;
      transform: translateY(-100%) rotateX(90deg);
    }
    75% {
      transform-origin: top;
      transform: translateY(100%) rotateX(90deg);
    }
    100% {
      transform-origin: top;
      transform: translateY(0%) rotateX(0deg);
    }
  }
  
  @keyframes animate2 {
    0% {
      transform: translateY(100%) rotateX(90deg);
    }
    25% {
      transform-origin: top;
      transform: translateY(0%) rotateX(0deg);
    }
    50% {
      transform-origin: bottom;
      transform: translateY(-100%) rotateX(90deg);
    }
    75% {
      transform-origin: bottom;
      transform: translateY(-100%) rotateX(90deg);
    }
    100% {
      transform-origin: top;
      transform: translateY(100%) rotateX(90deg);
    }
  }
  
  @keyframes animate3 {
    0% {
      transform: translateY(-100%) rotateX(90deg);
    }
    25% {
      transform-origin: top;
      transform: translateY(100%) rotateX(90deg);
    }
    50% {
      transform-origin: top;
      transform: translateY(0%) rotateX(0deg);
    }
    75% {
      transform-origin: bottom;
      transform: translateY(-100%) rotateX(90deg);
    }
    100% {
      transform-origin: bottom;
      transform: translateY(-100%) rotateX(90deg);
    }
  }
  
  @keyframes animate4 {
    0% {
      transform: translateY(-100%) rotateX(90deg);
    }
    25% {
      transform-origin: bottom;
      transform: translateY(-100%) rotateX(90deg);
    }
    50% {
      transform-origin: top;
      transform: translateY(100%) rotateX(90deg);
    }
    75% {
      transform-origin: top;
      transform: translateY(0%) rotateX(0deg);
    }
    100% {
      transform-origin: bottom;
      transform: translateY(-100%) rotateX(90deg);
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="main"&gt;
    &lt;div class="child1"&gt;Block 1&lt;/div&gt;
    &lt;div class="child2"&gt;Block 2!&lt;/div&gt;
    &lt;div class="child3"&gt;Block 3&lt;/div&gt;
    &lt;div class="child4"&gt;Block 4&lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>