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

              
                <div class='hero' id='one'>
  <div class='filter'></div>
  <h1 class='hero-text'>HELLO, WORLD 1</h1>
</div>

<div class='hero' id='two'>
  <div class='filter'>
    <h1 class='hero-text'>HELLO, WORLD 2</h1>
  </div>
</div>

<div class='hero' id='three'>
  <h1 class='hero-text'>HELLO, WORLD 3</h1>
</div>
              
            
!

CSS

              
                /*
Method 1: Intermediate element. Need to position and size it the same as the background. Notice the use of z-index to ensure that the siblings appear on top. Would have to apply this to all siblings.
*/
#one {
  .filter {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    backdrop-filter: blur(10px) brightness(90%);
    z-index: 2;
  }
  .hero-text {
    z-index: 3;
  }
}

/*
Method 2: Nesting elements. Doesn't require use of z-index, so adding more child elements isn't as complex. I think this is the best solution. 
*/
#two {
  /* down below, the .hero elements are all display flex, had to reset that here. In other cases, this won't be necessary*/
  display: block;
  .filter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100vw;
    height: 100vh;
    backdrop-filter: blur(10px) brightness(90%);
  } 
}

/*
Method 3: Child element the same size as parent. Least ideal, IMO, because it doesn't allow for other child elements/flex displays. Also requires some math to position the text. Also, doesn't allow for screen-height changes. Kinda the worst here, actually.
*/
#three {
  .hero-text {
    width: 100vw;
    backdrop-filter: blur(10px) brightness(90%);
    padding-top: calc(50% - .5em);
    padding-bottom: calc(50% - .5em);
  }
}

.hero {
  background-image: url(https://images.unsplash.com/photo-1526943604017-955071a1fb3e?ixlib=rb-1.2.1&ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&auto=format&fit=crop&w=1500&q=80);
  background-position: center center;
  background-repeat: no-repeat;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  .hero-text {
    color: white;
    padding: .35em;
    font-family: 'Old Standard TT', serif;
    font-size: 4em;
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console