title: How to animate background-position using percentages when background-size is 100%?
body: <p>Take the following example:</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>html {
      height: 100%;
  }
  
  body {
      display: flex;
      justify-content: center;
      align-items: center;
      background-color: black;
      height: 100%;
      margin: 0;
  }
  
  #main {
      background: #222222;
      position: relative;
      flex: 640px 0 0;
      height: 360px;
  }
  
  @keyframes stars {
   0% {
          background-position: 0 0;
      }
   100% {
          background-position: -100% 0;
      }
  }
  
  #stars {
      animation: stars 10s linear infinite;
      background-image: url('https://i.imgur.com/nyFndCj.png');
      background-size: 100% 100%;
      background-repeat: repeat repeat;
      position: absolute;
      width: 100%;
      height: 100%;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="main"&gt;
    &lt;div id="stars"&gt;&lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>The idea here is to animate the stars moving from one side to the other by changing the background position <strong>using percentages</strong>. I can get this working using <code>px</code>, for instance, but that requires me to know the width in advance (in this case <code>640px</code>) and if I want to change the width/height of <code>#main</code> I need to change the animation values and I want to avoid that, thus the percentages. Also, I want to acomplish this with CSS only, no JavaScript at all.</p>