title: CSS rotate transform messes up hover on sibling element
body: <p>Im trying to implement an overlay on an image element, with a button inside that lets you rotate the image 180 degrees. This works fine until you rotate the image the first time, then the overlay will not show up again or is for some reason behind the image tag, i have tried setting the z-index of the image to -999 but that did not do anything. I need the solution to work on mobile to, so working with onmouseover event listeners wasnt an option for me.</p>
  <p><a href="https://codesandbox.io/s/black-wildflower-dlpzq?file=/src/styles.css:272-343" rel="nofollow noreferrer">Code Sandbox here</a></p>
  <p>Code:</p>
  <pre><code>&lt;div class=&quot;relative&quot;&gt;
      &lt;div class=&quot;absolute overlay&quot;&gt;
         &lt;button id=&quot;rotate&quot;&gt;Click to Rotate this Image 180 Degrees&lt;/button&gt;
      &lt;/div&gt;
      &lt;div&gt;
        &lt;img id=&quot;image-to-rotate&quot; src=&quot;https://picsum.photos/200/300&quot; /&gt;
     &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  <pre><code>import &quot;./styles.css&quot;;
  
  document.getElementById(&quot;rotate&quot;).addEventListener(&quot;click&quot;, () =&gt; {
    document.getElementById(&quot;image-to-rotate&quot;).classList.toggle(&quot;rotate&quot;);
  });
  </code></pre>
  <pre><code>
  .relative {
    position: relative;
    height: 300px;
    width: 200px;
  }
  
  .absolute {
    color: white;
    position: absolute;
    background-color: rgba(0, 0, 0, 0.6);
    height: 100%;
    width: 100%;
    /*invisible by default*/
    opacity: 0;
  }
  
  .absolute:hover,
  .absolute:active {
    /*show on hover, also on activate to work on mobile*/
    opacity: 1;
  }
  .rotate {
    transform: rotate(180deg);
  }
  
  </code></pre>