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="resizer"></div>

<button id="button" type="button" popovertarget="popover">
  Discover Winter Wonders
  <sup>❄︎</sup>
</button>

<div anchor="button" id="popover" popover>❄︎ The presence of snow does not mean climate change is not happening.</div>


<dialog open id="fallback">
  <p>Your browser does not support anchor positioning.</p>
  <p>To play with this demo, open it in Chrome Canary with the “Experimental web platform features” feature flag on.</p>
  <p>Here is a screen recording of this demo:</p>
  <video controls muted playsinline preload="none" poster="https://kizu.dev/videos/anchor-positioning-button-dark.jpg">
    <source src="https://kizu.dev/videos/anchor-positioning-button-dark.mp4" type="video/mp4" media="(prefers-color-scheme: dark)">
    <source src="https://kizu.dev/videos/anchor-positioning-button-light.mp4" type="video/mp4">
    Sorry, your browser doesn’t support embedded videos. You can <a href="https://kizu.dev/videos/anchor-positioning-button-dark.mp4">download it</a>.
  </video>
  <p><button type="button" onclick="fallback.close()">Close this dialog</button></p>
</dialog>

              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css2?family=Playpen+Sans:wght@100..800&display=swap');


button {
  position: relative;
  cursor: pointer;
  grid-area: --button;
  font: inherit;
  border: 1px solid transparent;
  box-shadow: 1px 2px 2px 1px forestgreen;
  color: #000;
  background: lightgreen;
  border-radius: 9em;
}

sup {
  position: absolute;
  inset-block-start: -0.25ex;
  inset-inline-end: -0.75ex;
  line-height: 1ex;
  font-size: 1.5em;
  anchor-name: --sup;

  @media (prefers-color-scheme: dark) {
    color: #FFF;
    font-weight: bold;
  }
}

[popover] {
  padding: 0.5em;
  border-radius: 0.25em;
  text-align: center;

  min-width: anchor-size(inline);
  max-width: 20em;
  anchor-name: --popover;
  grid-area: --fallback;
    
  &::before,
  &::after {
    content: "";
    position: fixed;
    width: anchor-size(inline);
    position-anchor: --sup;
    background: inherit;
    inset-inline: anchor(start) anchor(end);
    max-height: anchor-size(inline);
    margin: auto;
    inset-block-start: calc(anchor(end) + 0.5em);
    inset-block-end: calc(anchor(--popover start) - 0.5em);
    transform: translateY(16.666%) rotate(45deg);
    box-shadow: inset 1.5px 1.5px;
  }
  &::after {
    inset-block-start: calc(anchor(--popover end) - 0.5em);
    inset-block-end: calc(anchor(start));
    transform: translateY(calc(-16.666%)) rotate(45deg);
    box-shadow: inset -1.5px -1.5px;
  }
  
  &::backdrop {
    position: absolute;
    inset: anchor(start) anchor(end) anchor(end) anchor(start);
    border-radius: 9em;
    outline: 100vmax solid #0074
  }
}

@supports (anchor-name: --foo) {
  [popover] {
    /* Old anchor-center algorithm */
    inset-inline: calc(
      anchor(50%)
      -
      min(
        abs(0% - anchor(50%)),
        abs(100% - anchor(50%))
      )
    );
    margin-inline: auto;
    position-try: flip-block;
    inset-block-start: auto;
    inset-block-end: max(anchor(start), anchor(--sup start) + 0.5em);
    margin-block: 0.25em;
  }
}

/* Page and resizer setup */

html {
  color-scheme: dark light;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  --resizer-area: 1fr;
  grid-template:
    '--resizer . .' var(--resizer-area)
    '. --button .' max-content
    '. --fallback .' 1fr / var(--resizer-area) max-content 1fr;
  place-items: center;
  font-family: Playpen Sans, sans-serif;
}

body:has(.resizer[style]) {
  --resizer-area: max-content;
}

.resizer {
  overflow: hidden;
  resize: both;
  width: 100%;
  height: 100%;
  grid-area: --resizer;
}

dialog {
  z-index: 9;
  outline: 200vmax solid #1238;
  overflow: auto;
  max-height: 100vh;
  box-sizing: border-box;
}

video {
  max-width: 100%;
  max-height: 100vh;
  width: 722px;
  height: 414px;
}

@supports (anchor-name: --foo) {
  dialog {
    display: none;
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console