title: CSS :after behind parent element
body: <p>Is it possible to get a CSS pseudo <code>:after</code> element behind the background of it's parent element?  </p>
  
  <p>The background of the <code>:after</code> contains equal dimensions as the parent element's background. So currently it looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/RZbxy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RZbxy.png" alt="enter image description here"></a></p>
  
  <p>But I want the red background (<code>:after</code>) to go behind the parent element. 
  So I've added <code>position: relative</code> to the parent and <code>absolute</code> to the pseudo element.</p>
  
  <p>Trying to archive this I've used this code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.btn {
    position: relative;
    display: inline-block;
    padding: .8rem 1rem;
    font-size: 1rem;
    background: #000;
  }
  
  .btn:after {
    position: absolute;
    bottom: -0.3rem; right: -0.3rem;
    z-index: -1;
  
    width: 100%; height: 100%;
    content:'';
    background: red;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;a href="" class="btn"&gt;
    This is my button
  &lt;/a&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>The weird thing is that above snippet works like charm. But in my <a href="http://www.capybaras.nl/" rel="nofollow noreferrer">live example</a> the exact same code displays as the image in this topic.. Someone knows what is wrong in the live site?</p>