Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

Save Automatically?

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

              
                <div class="img-container">
  <img src="https://picsum.photos/1200/1200" alt="" class="img-blur" aria-hidden="true">
  <img src="https://picsum.photos/1200/1200" alt="Placeholder image">
</div>

<div class="img-container">
  <img src="https://picsum.photos/1200/2400" alt="" class="img-blur" aria-hidden="true">
  <img src="https://picsum.photos/1200/2400" alt="Placeholder image 2">
</div>

<div class="img-container">
  <img src="https://picsum.photos/1200/500" alt="" class="img-blur" aria-hidden="true">
  <img src="https://picsum.photos/1200/500" alt="Placeholder image 2">
</div>

<p>
  Demo by <a target="_blank" href="https://twitter.com/Martijn_Cuppens">Martijn Cuppens</a>, photos from <a target="_blank" href="https://picsum.photos/">Lorem picsum</a>
</p>
              
            
!

CSS

              
                // Center the containers
body {
  display: grid;
  place-items: center;
}

// The image containers
.img-container {
  width: 100%;
  max-width: 600px;
  position: relative;
  overflow: hidden;
  margin-bottom: 2rem;
}

// Add a pseudo element to keep the aspect ratio
.img-container::after {
  content: "";
  display: block;
  padding-bottom: calc(900% / 16);  // Define ratio here
}

// Stretch the images over the container and keep them contained
.img-container > * {
  position: absolute;
  top: var(--offset, 0);
  left: var(--offset, 0);
  width: calc(100% - 2 * var(--offset, 0px));
  height: calc(100% - 2 * var(--offset, 0px));
  object-fit: contain;
}

// Blur the background image and cover the whole container
// Use the negative blur value as offset to prevent the blur 
// from mixing with the document background color
.img-blur {
  --blur: 20px;
  --offset: calc(-1 * var(--blur));
  object-fit: cover;
  filter: blur(var(--blur));
}

// Footer theming
p {
  text-align: center;
  color: #666;
  font-family: sans-serif;
  
  a {
    color: #2073c5;
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console