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="worklet-canvas"></div>
<div class="prompt">
  <p>
    Psst... resize the browser and watch the pattern re-arrange itself! ✨
  </p>
  <div class="prompt__buttons">
    <a class="prompt__button prompt__button--fullscreen" href="https://cdpn.io/georgedoescode/debug/db3de4da463af459f040d517827ca22b" target="_blank">Full Screen</a>
    <button class="prompt__button prompt__button--regenerate">Regenerate</button>
  </div>

</div>
              
            
!

CSS

              
                * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
  font-family: "Poppins", sans-serif;
  line-height: 1.5;
  background: #1d1934;
  color: #1d1934;
  padding: 1.5rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.worklet-canvas {
  --fluid-pattern-seed: 123456;
  --fluid-pattern-bg-color: #1d1934;
  --fluid-pattern-color-1: #ffd53d;
  --fluid-pattern-color-2: #f0f1ff;
  --fluid-pattern-color-3: #f25c54;
  --fluid-pattern-color-4: #48cb8a;

  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;

  background-image: paint(fluidPattern);
}

.prompt {
  position: relative;
  padding: 1.5rem;
  background: hsla(0, 100%, 100%, 0.75);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  backdrop-filter: blur(16px) saturate(180%);
  box-shadow: 0px 4px 16px 0px hsla(0, 0%, 0%, 0.125);
  border-radius: 1rem;
  z-index: 1;
  border: 1px solid hsla(0, 0%, 100%, 0.9);
  font-weight: 700;
  letter-spacing: -0.025em;
  max-width: 26rem;
  text-align: center;
}

.prompt p {
  font-size: 1.125rem;
  margin-bottom: 1.5rem;
}

.prompt__buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-gap: 1rem;
}

.prompt__button {
  width: 100%;
  display: block;
  height: 2.75rem;
  line-height: 2.75rem;
  background: #1d1934;
  color: #fff;
  border: 0;
  font-weight: 600;
  border-radius: 0.5rem;
  font-family: inherit;
  cursor: pointer;
  font-size: 0.875rem;
  text-decoration: none;
}

.prompt__button--fullscreen {
  background: #fff;
  color: #1d1934;
}

@media only screen and (max-width: 480px) {
  .prompt__buttons {
    grid-template-columns: 1fr;
  }
}

              
            
!

JS

              
                (async function () {
  // Uh oh! No Paint API support...
  if (CSS["paintWorklet"] === undefined) {
    // Let the user know they can't experiment with the pattern
    document.querySelector(
      ".prompt p"
    ).innerHTML = `Ah... the CSS Paint API is not supported in this browser — try Chrome or Edge!`;

    // Disable the regeneration button
    document.querySelector(".prompt__button--regenerate").style.opacity = "0.5";
    document.querySelector(".prompt__button--regenerate").style.pointerEvents =
      "none";
  } else {
    // Source: https://github.com/georgedoescode/fluid-pattern-worklet/blob/main/worklet.js
    CSS.paintWorklet.addModule(
      "https://unpkg.com/@georgedoescode/fluid-pattern-worklet"
    );
    // Update the pattern seed on click
    document
      .querySelector(".prompt__button--regenerate")
      .addEventListener("click", () => {
        document
          .querySelector(".worklet-canvas")
          .style.setProperty("--fluid-pattern-seed", Math.random() * 10000);
      });
  }

  if (!inIframe()) {
    document.querySelector(".prompt__button--fullscreen").style.display =
      "none";
    document.querySelector(".prompt__buttons").style.gridTemplateColumns =
      "1fr";
  }
})();

function inIframe() {
  try {
    return window.self !== window.top;
  } catch (e) {
    return true;
  }
}

              
            
!
999px

Console