title: CSS transition on load via JQUERY
body: <p>I'm trying to write some code to cause a transition on load, so I basically have some jquery adding a class, <code>transition-left</code> to a div and some css that says to move left if it has the class <code>transition-left</code>. However, even though the class is being added, the transition isn't happening. I just don't know why that is the case. Here is my 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-js lang-js prettyprint-override"><code>$(document).ready(function () {
      $("#curtain-left").addClass("transition-left");
  });
  
  $(document).ready(function () {
      $("#curtain-right").addClass("transition-right");
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.curtain {
   width: 100vw;
   height: 100vh;
   overflow: hidden;
   z-index: 0;
  
   /* CSS variables to prevent duplication below */
   --piece-width: 100px;
  }
  
  .curtain .content {
   /* I used flex since I'm more comfortable with that, but you can use floats if you prefer. */
   display: flex;
   align-items: center;
   justify-content: center;
   width: 100%;
   height: 100%;
   z-index: 0;
  }
  
  .curtain-panel {
   display: flex;
   align-items: center;
   position: absolute;
   width: 50%;
   height: 100%;
  
   transition: left, right;
   transition-duration: 3s;
  }
  
  .curtain-panel.left {
   left: 0;
   justify-content: end;
  }
  
  .curtain-panel.right {
   right: 0;
  }
  
  .curtain-panel::before {
   content: "";
   position: absolute;
   top: 0;
   left: 0;
   right: 0;
   bottom: 0;
   z-index: 1;
  
   background-color: #333;
  }
  
  .curtain-piece-left {
   width: var(--piece-width);
   height: auto;
   z-index: 2;
   margin: calc(100% - var(--piece-width) / 2);
  }
  
  .curtain-piece-right {
   width: var(--piece-width);
   height: auto;
   z-index: 2;
   margin: calc(var(--piece-width) / -2);
  }
  
  .transition-left{
   left: -100%;
  }
  
  .transition-right{
   right: -100%;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
    &lt;link rel="stylesheet" href="css/curtain.css" /&gt;
    &lt;link rel="stylesheet" href="css/index.css" /&gt;
    &lt;link href="./css/bootstrap.css" rel="stylesheet"&gt;
    &lt;link href="./css/index.css" rel="stylesheet"&gt;
    &lt;link href="./css/starter-template.css" rel="stylesheet"&gt;
      &lt;!-- Let browser know website is optimized for mobile
        &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"/&gt; --&gt;
    &lt;/head&gt;
  
    &lt;body&gt;
      &lt;div class="curtain"&gt;
        &lt;div class="curtain-panel left"&gt;
          &lt;img src="https://getsharex.com/img/ShareX_Icon_Full.ico" class="curtain-piece-left" id="curtain-left"/&gt;
        &lt;/div&gt;
        &lt;div class="curtain-panel right"&gt;
          &lt;img src="https://lh3.googleusercontent.com/proxy/p0uNfB1-JwEd_zQfXuiMQmhxkAszQSH19V-ff6kH9_5LS4eWHsZdFQnshtP3tSLDhBuRNb2AV0RD9UGbci0bEeNeHs4Acr5RABX5TJlrQXykGCgt8wUnEgFkGLlIPm-H4Tg7oHiwfH0MnJzdrg" class="curtain-piece-right"  id="curtain-right"/&gt;
        &lt;/div&gt;
        &lt;div class="content"&gt;
          &lt;nav class="navbar navbar-expand-md navbar-dark bg-purple fixed-top"&gt;
            &lt;a class="navbar-brand" href="#"&gt;a&lt;/a&gt;
            &lt;button
              class="navbar-toggler"
              type="button"
              data-toggle="collapse"
              data-target="#navbarsExampleDefault"
              aria-controls="navbarsExampleDefault"
              aria-expanded="false"
              aria-label="Toggle navigation"
            &gt;
              &lt;span class="navbar-toggler-icon"&gt;&lt;/span&gt;
            &lt;/button&gt;
  
            &lt;div class="collapse navbar-collapse" id="navbarsExampleDefault"&gt;
              &lt;ul class="navbar-nav mr-auto"&gt;
                &lt;li class="nav-item"&gt;
                  &lt;a class="nav-link" href="#"
                    &gt;Home &lt;span class="sr-only"&gt;(current)&lt;/span&gt;&lt;/a&gt;
                &lt;/li&gt;
                &lt;li class="nav-item"&gt;
                  &lt;a class="nav-link" href="#"&gt;b&lt;/a&gt;
                &lt;/li&gt;
                &lt;li class="nav-item"&gt;
                  &lt;a class="nav-link" href="#"&gt;c&lt;/a&gt;
                &lt;/li&gt;
                &lt;li class="nav-item"&gt;
                  &lt;a class="nav-link" href="#"&gt;d&lt;/a&gt;
                &lt;/li&gt;
                &lt;li class="nav-item"&gt;
                  &lt;a class="nav-link" href="#"&gt;e&lt;/a&gt;
                &lt;/li&gt;
              &lt;/ul&gt;
            &lt;/div&gt;
          &lt;/nav&gt;
  
          &lt;main role="main" class="container"&gt;
            &lt;div class="starter-template"&gt;
              &lt;h1&gt;Template&lt;/h1&gt;
              &lt;p class="lead"&gt;
                Use this document as a template for other pages.&lt;br /&gt;
                Keep in mind, Bootstrap documentation might be needed to build
                components of the other pages.
              &lt;/p&gt;
            &lt;/div&gt;
          &lt;/main&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;!-- Bootstrap core JavaScript --&gt;
      &lt;script
        src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
        integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
        crossorigin="anonymous"
      &gt;&lt;/script&gt;
  
      &lt;script src="./js/bootstrap.min.js"&gt;&lt;/script&gt;
      &lt;script src="js/curtain.js"&gt;&lt;/script&gt;
      &lt;script src="jquery-3.4.1.min.js"&gt;&lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>