title: Animate a line under a hyperlink using only CSS
body: <p>I'm trying to animate a line in a particular way <a href="https://i.stack.imgur.com/o8THi.gif" rel="nofollow noreferrer">(see the following gif for a visual representation)</a> under a hyperlink using the following code structure:</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>.navlink {
    position: relative;
    color: white;
  }
  
  .navlink a {
    display: inline-block;
    margin: 0;
    text-decoration: none;
  }
  
  .navlink a::after {
    display: block;
    content: '';
    border-bottom: solid 0.2vmax red;
    transform: scaleX(0);
    transition: transform 250ms ease-in-out;
  }
  
  .navlink a:hover::after {
    animation: scaleup 3s forwards;
  }
  
  @keyframes scaleup {
    50% {
      transform: scaleX(1)
    }
    100% {
      transform-origin: 50% 0, scaleX(0)
    }
  }
  
  .navlink a:after {
    transform-origin: 0% 50%;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;nav id="main-nav"&gt;
    &lt;div class="main-nav-content"&gt;
      &lt;div class="navlink"&gt;
        &lt;a href="/aboutus.html"&gt;
          &lt;span&gt;About Us&lt;/span&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/nav&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>I can get the line to animate in one direction OK but having problem with the second half of the animation. Can anyone help me understand a better way to do this using only CSS?</p>