title: CSS overlay with animation
body: <p>I am trying to create an overlay with the following html and css</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>div.relative {
    position: relative;
    width: 400px;
    height: 200px;
    border: 3px solid #73AD21;
  }
  
  div.absolute {
    position: absolute;
    top: 50%;
    right: 0;
    width: 200px;
    height: 100px;
    border: 3px solid #73AD21;
    opacity: 1;
    background-color: blue;
  }
  
  .overlay {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.95);
    color: white;
    z-index: 1;
  }
  
  .div1 {
    animation: 750ms 1 forwards ani;
  }
  
  @keyframes ani {
    0% {
      opacity: 0;
    }
    100% {
      opacity: 1;
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;h2&gt;
    position: absolute;&lt;/h2&gt;
  
  &lt;p&gt;An element with position: absolute; is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed):&lt;/p&gt;
  
  &lt;div class="relative"&gt;
    This div element has position: relative;
    &lt;div class="div1"&gt;
      This is a div
      &lt;div class="overlay"&gt;
        This div element has position: fixed;
      &lt;/div&gt;
    &lt;/div&gt;
  
    &lt;div class="absolute"&gt;
      This div element has position: absolute;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I am trying to create an overlay which is supposed to cover the entire area. However, the problem is, when I add animation it brings the absolute element to the front despite the fact that the animation has not been applied to it</p>