title: CSS Show the same animation in different ways on different devices
body: <p>I have an element which has a class, for instance <code>.anim</code>. I want to achieve that when the user plays the animation on mobile, the element with the <code>anim</code> class should be turned blue, but on desktop it should be red.
  Is it even possible to achieve?</p>
  <p>Here's the code what I've tried so far</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>var box = document.getElementsByClassName('box');
  document.getElementById("play").addEventListener("click", () =&gt; {
    box[0].classList.add('anim');
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.box {
    display: flex;
    width: 4rem;
    height: 4rem;
    border: 1px dashed gray;
  }
  
  .anim {
  animation-name: rainbow;
  animation-duration: .25s;
  animation-timing-function: ease-in-out;
  }
  
  @media only screen and (min-width: 992px) { /* Desktop */
    @keyframes rainbow { 0% {background-color: unset;} 100% { background-color: red !important; } }
  }
  
  /* Mobile */
  @keyframes rainbow { 0% {background-color: unset;} 100% { background-color: blue; } }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="box"&gt;&lt;/div&gt;&lt;br&gt;
  &lt;button id="play"&gt;Play&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>