title: CSS Animation - text sliding left to right
body: <p>I'm trying to get some text to slide in from left to right with a delay. It will be appearing from the middle of the page rather than off canvas. I can easy get it to work when the text slides in from off the page. </p>
  
  <p>Doing from the middle of the screen is a little different and i'm missing something. The text appears on page load (when it should be hidden). I can easy do this using jQuery, but i'm sure it's more than possible to do using just css. Here's what i got so far</p>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>&lt;div class="slide-right"&gt;
    &lt;h2&gt;Text that will slide in from the left&lt;/h2&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>CSS:</strong></p>
  
  <pre><code>.slide-right {
     width: 100%;
     overflow: hidden;
     margin-left: 400px;
     max-width: 500px
  }
  
  .slide-right h2 {
     animation: 2s slide-right;
     animation-delay: 2s;
  }
  
  @keyframes slide-right {
      from {
         margin-left: -500px;
      }
  
      to {
         margin-left: 0%;
      }
   }
  </code></pre>
  
  <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>.slide-right {
    width: 100%;
    overflow: hidden;
    margin-left: 400px;
    max-width: 500px
  }
  
  .slide-right h2 {
    animation: 2s slide-right;
    animation-delay: 2s;
  }
  
  @keyframes slide-right {
    from {
      margin-left: -500px;
    }
  
    to {
      margin-left: 0%;
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="slide-right"&gt;
    &lt;h2&gt;Text that will slide in from the left&lt;/h2&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><a href="https://i.stack.imgur.com/909L0.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/909L0.gif" alt="Like this"></a></p>
  
  <p>Thanks</p>