title: Displaying Loading Image using CSS
body: <p>I currently have the following CSS code that I apply to a <code>div</code> element that displays a responsive image.</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>.my-img-container {
    position: relative;
    &amp;:before {
      display: block;
      content: " ";
      background: url("https://lorempixel.com/300/160/") no-repeat;
      background-size: 100% 100%;
      width: 100% !important;
      padding-top: 56.25%;
    }
    &gt;img {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      width: 100% !important;
      height: 100% !important;
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="my-img-container"&gt;
    &lt;img srcset="https://lorempixel.com/540/304 540w, https://lorempixel.com/960/540 960w" sizes="(min-width: 576px) 540px, 100vw" src="https://lorempixel.com/300/160"&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>What I'm trying to do is have an image display in the background while the responsive image is loading, hence the <code>content</code> in the CSS, but it's not working. Any idea why?</p>