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

              
                <section class="wrapper">
  <div class="gradient"></div>
  <div class="content">
    <h1>Blend mode and stacking context</h1>
    <p>The stacking context has a huge impact on whether or not a blend mode will work. <a href="https://stackoverflow.com/a/56545440">This StackOverflow answer</a> has a good run down of examples. The problem is that the behavior is pretty different between browsers. Take a look at this pen in Chrome vs Safari, for example. As of now (17 Nov 2021), the images below blend appropriately with the background in Chrome and Firefox, but not in Safari. :(</p>
    <img src="https://piperhaywood.com/wp-content/uploads/2021/02/piper-haywood_rat-beach-2010.jpg" alt="RAT beach in Torrance, CA"/>
    <p>Cras mattis consectetur purus sit amet fermentum. Maecenas faucibus mollis interdum. Nulla vitae elit libero, a pharetra augue. Etiam porta sem malesuada magna mollis euismod. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Cras mattis consectetur purus sit amet fermentum.</p>
    <img src="https://piperhaywood.com/wp-content/uploads/2021/02/piper-haywood_lunada-bay-2010.jpg" alt="Lunada Bay, CA" />
  </div>
</section>
              
            
!

CSS

              
                /* The CSS relevant to demonstrate the blend mode and stacking context issues */

.gradient {
  background: linear-gradient(
    180deg,
    red 10%,
    cyan 90%
  );
  height: 100%;
  left: 0;
  position: fixed;
  top: 0;
  width: 100%;
}

.content {
  position: relative;
}

img {
  mix-blend-mode: overlay;
}

/* Other stuff */

html {
  color: white;
  font-family: sans-serif;
}

a {
  color: inherit;
}

a:hover {
  text-decoration-line: none;
}

.content {
  margin: 0 auto;
  max-width: 55rem;
  padding: 5vw;
}

img {
  max-width: 30rem;
}
              
            
!

JS

              
                
              
            
!
999px

Console