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="menu">
  <button class="menu-toggle" id="menu-toggle" popovertarget="menu-items">
    <div aria-hidden="true">➕</div>
    <div class="sr-only">open menu</div>
  </button>
  <menu class="menu-items" id="menu-items" popover anchor="menu-toggle">
    <li class="item">
      <button>
        <div aria-hidden="true">♥️</div>
        <div class="sr-only">add to favorites</div>
      </button>
    </li>
    <li class="item">
      <button>
        <div aria-hidden="true">💾</div>
        <div class="sr-only">save to collection</div>
      </button>
    </li>
    <li class="item">
      <button>
        <div aria-hidden="true">🔗</div>
        <div class="sr-only">copy link</div>
      </button>
    </li>
    <li class="item">
      <button>
        <div aria-hidden="true">✉️</div>
        <div class="sr-only">email</div>
      </button>
    </li>
    <li class="item">
      <button>
        <div aria-hidden="true">🛒</div>
        <div class="sr-only">add to cart</div>
      </button>
    </li>
    <!--  Need extra close button bc the popover lays on top of the X and doesn't let you get to it    -->
    <li class="item">
      <button popovertargetaction="close" popovertarget="menu-items" class="hidden-close">
        <div aria-hidden="true"> </div>
        <div class="sr-only">close menu</div>
      </button>
    </li>
  </menu>
</div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css2?family=Noto+Emoji:wght@600&display=swap');

:root {
  --btn-size: 3rem;
  --extra-space: 1.5rem;
}

/* Where the magic happens */
.item {
  --radius: calc(var(--btn-size) + var(--extra-space));
  background-color: var(--bg);
  transform: translateX(calc(cos(var(--angle)) * var(--radius)))
		         translateY(calc(sin(var(--angle) * -1) * var(--radius)))
             rotate(0deg);
  opacity: 0;
  transition: all 0.3s var(--delay) ease;
}

/* Adding for popover base */

.menu-items:not(:popover-open) .item {
  --radius: 0;
  --angle: 0;
  rotate: 45deg;
}

/* rotate the "plus" */
.menu-toggle > div {
  transition: transform 0.3s;
}

.menu:has(:popover-open) .menu-toggle > div {
  transform: rotate(45deg);
}

.menu-items {
  bottom: calc(anchor(bottom));
  left: anchor(center);
  translate: -50% 0;
  /*  popover override  */
  background: none;
}

.hidden-close {
  transform: rotate(45deg);
  transition: opacity 0.1s;
  transition-delay: 1s;
  width: var(--btn-size);
  aspect-ratio: 1;
}

:popover-open .item {
  opacity: 1;
}

/* Every item gets a background, angle, and delay */
/* This gets updated when the popover is open */

.item:nth-child(1) {
  --bg: pink;
  --angle: 0deg;
  --delay: 0s;
}

.item:nth-child(2) {
  --bg: thistle;
  --angle: 45deg;
  --delay: 0.1s;
}

.item:nth-child(3) {
  --bg:	paleturquoise;
  --angle: 90deg;
  --delay: 0.2s;
}

.item:nth-child(4) {
  --bg: lightgreen;
  --angle: 135deg;
  --delay: 0.3s;
}

.item:nth-child(5) {
  --bg: peachpuff;
  --angle: 180deg;
  --delay: 0.4s;
}

/* Not related to demmo, just styling */

.item {
  border-radius: 50%;
  width: var(--btn-size);
  aspect-ratio: 1;
}

.menu-toggle {
  border-radius: 50%;
  width: var(--btn-size);
  aspect-ratio: 1;
  background: darksalmon;
  z-index: 1;
}

/* Grid piles */

.menu,
.menu-items,
body,
.item {
  display: grid;
  place-content: center;
}

.menu > *,
.menu-items > *,
body > *
.item button {
  grid-area: 1/1;
}

/* Resets, etc. */
/* visually-hidden ala https://www.scottohara.me/blog/2017/04/14/inclusively-hidden.html */
.sr-only {
  clip: rect(0 0 0 0); 
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap; 
  width: 1px;
}

button {
  border: none;
  background: none;
  font-family: 'Noto Emoji';
  color: #222;
  font-size: 1.25rem;
}

button:focus-visible {
  outline: 2px dashed deeppink;
  border-radius: 50%;
  aspect-ratio: 1/1;
}

body {
  height: 100vh;
}

.menu, .menu-items {
  overflow: unset;
}
              
            
!

JS

              
                
              
            
!
999px

Console