Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <picture style="--h:9;--w:16;">
  <source 
    media="(max-width: 767px)"
    srcset="
    https://assets.stoumann.dk/img/coffee-dark-small.jpg?w=250 250w,
    https://assets.stoumann.dk/img/coffee-dark-small.jpg?w=450 450w,
    https://assets.stoumann.dk/img/coffee-dark-small.jpg?w=650 650w,
    https://assets.stoumann.dk/img/coffee-dark-small.jpg?w=850 850w,
    https://assets.stoumann.dk/img/coffee-dark-small.jpg?w=1050 1050w,
    https://assets.stoumann.dk/img/coffee-dark-small.jpg?w=1250 1250w,
    https://assets.stoumann.dk/img/coffee-dark-small.jpg?w=1450 1450w,
    https://assets.stoumann.dk/img/coffee-dark-small.jpg?w=1650 1650w
    "
    sizes="
    (min-width: 768px) and (max-width: 1199px) 50vw,
    (min-width: 1200px) 33vw,
    100vw"
  >

  <source 
    media="(min-width: 768px)"
    srcset="
    https://assets.stoumann.dk/img/coffee-dark-large.jpg?w=250 250w,
    https://assets.stoumann.dk/img/coffee-dark-large.jpg?w=450 450w,
    https://assets.stoumann.dk/img/coffee-dark-large.jpg?w=650 650w,
    https://assets.stoumann.dk/img/coffee-dark-large.jpg?w=850 850w,
    https://assets.stoumann.dk/img/coffee-dark-large.jpg?w=1050 1050w,
    https://assets.stoumann.dk/img/coffee-dark-large.jpg?w=1250 1250w,
    https://assets.stoumann.dk/img/coffee-dark-large.jpg?w=1450 1450w,
    https://assets.stoumann.dk/img/coffee-dark-large.jpg?w=1650 1650w
    "
    sizes="
    (min-width: 768px) and (max-width: 1199px) 50vw,
    (min-width: 1200px) 33vw,
    100vw"
  >
  <img
    alt="A up of coffee"
    crossorigin="anonymous"
    decoding="async"
    id="img"
    loading="lazy"
    src="https://assets.stoumann.dk/img/coffee-light-small.jpg" />
</picture>
<code id="code"></code>
<p>Markup rendered with <a href="https://codepen.io/stoumann/pen/abpzVGW">Responsive Image Configurator</a>.<br />You have to <strong>resize</strong> the browser to see the image change.</p>

              
            
!

CSS

              
                body {
  font-family: ui-sans-serif, system-ui, sans-serif;
  margin: 0;
  padding: 0.5rem;
}
code {
  background-color: black;
  color: lime;
  display: block;
  font-size: small;
  margin: 0.5rem 0;
  padding: 0.5rem;
  word-break: break-all;
}
img {
  max-width: 100%;
  width: 100%;
}
picture {
  display: block;
  position: relative;
}
picture::after {
  content: '';
  display: block;
  padding-bottom: calc((var(--h, 9) / var(--w, 16)) * 100%)
}
picture img {
  bottom: 0;
  height: 100%;
  left: 0;
  object-fit: cover;
  object-position: center center;
  position: absolute;
  right: 0;
  top: 0;
  width: 100%;
}
@media only screen and (min-width: 768px) {
  img, picture {
    width: 50vw;
  }
}
@media only screen and (min-width: 1200px) {
  img, picture {
    width: 33vw;
  }
}
@media (prefers-color-scheme: dark) {
  body {
    background-color: #222;
  }
}
              
            
!

JS

              
                const L = window.matchMedia('(min-width: 1200px)');
const M = window.matchMedia('(min-width: 768px) and (max-width: 1199px)');
const RO = new ResizeObserver(() => {
  code.innerText = `DPR: ${window.devicePixelRatio}\nSRC: ${img.currentSrc}\nQRY:${M.matches ? ' 768px – 1199px: 50vw': L.matches ? ' +1200px: 33vw' : ' 0 – 767px: 100vw'}`;
});
RO.observe(img);
              
            
!
999px

Console