<h1>Scaling a <code>&lt;div&gt;</code> to Match an SVG Background Image Aspect Ratio</h1>
<figure>
  <figcaption>CSS background image, wrapper set to 100px wide</figcaption>
  <div style="width:100px">
    <div class="bg-svg">
  </div>
</figure>
<figure>
  <figcaption>CSS background image, wrapper set to 50% wide</figcaption>
  <div style="width: 50%">
    <div class="bg-svg">
  </div>
</figure>
<figure>
  <figcaption>CSS background image, full width</figcaption>
  <div>
    <div class="bg-svg">
  </div>
</figure>
.bg-svg {
  width: 100%;
  background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/91525/potofgold.svg);
  background-size: cover;
  height: 0;
  padding: 0; /* reset */
  padding-bottom: 92%;
  border: thin dotted darkgrey;
}
figure > div {
  margin: 1em auto;
}

External CSS

  1. https://codepen.io/AmeliaBR/pen/4f71235e7f30093e5c454baa65ad19e1.css

External JavaScript

This Pen doesn't use any external JavaScript resources.