title: Adding transparent overlay to div
body: <p>I'm trying to add an overlay over a <code>div</code> which houses an image. I've seen approaches which add an overlay to background images, but can't seem to figure out why it doesn't work for divs?</p>
  
  <p>Approach:</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>.featured-image {
    height: 338px;
    position: relative;
    overflow: hidden;
  }
  
  .overlay {
    background-color: rgba(0, 0, 0, 0.6);
    width: 100%;
    height: 100%;
    z-index: 2;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="featured-image"&gt;
    &lt;div class="overlay"&gt;
      &lt;img src="https://img.freepik.com/free-vector/abstract-low-poly-design-background_1048-8196.jpg?size=338c&amp;ext=jpg"&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>