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="container">
  <div class="card">
    <figure class="image">
      <img src="https://i.pinimg.com/564x/4d/9a/24/4d9a24c5ba21ad961541b5f5b7f7cad1.jpg" alt="Nail art">
    </figure>
    <div class="overlay">
      <!--   Menu component  -->
      <div class="menu">
        <button tabindex=1 class="menu-toggle" style="anchor-name: --menu-toggle-1" popovertarget="menu-items-1">
          <span aria-hidden="true">➕</span>
          <span class="sr-only">open menu</span>
        </button>
        <ul class="menu-items" id="menu-items-1" popover style="position-anchor: --menu-toggle-1" role="menu">
          <li class="item">
            <button role="menuitem">
              <span aria-hidden="true">♥️</span>
              <span class="sr-only">add to favorites</span>
            </button>
          </li>
          <li class="item">
            <button role="menuitem">
              <span aria-hidden="true">💾</span>
              <span class="sr-only">save to collection</span>
            </button>
          </li>
          <li class="item">
            <button role="menuitem">
              <span aria-hidden="true">🔗</span>
              <span class="sr-only">copy link</span>
            </button>
          </li>
          <li class="item">
            <button role="menuitem">
              <span aria-hidden="true">✉️</span>
              <span class="sr-only">email</span>
            </button>
          </li>
          <li class="item">
            <button role="menuitem">
              <span aria-hidden="true">🛒</span>
              <span class="sr-only">add to cart</span>
            </button>
          </li>
          <li class="item">
            <button popovertargetaction="hide" popovertarget="menu-items-1" class="hidden-close">
              <span aria-hidden="true"> </span>
              <span class="sr-only">close menu</span>
            </button>
          </li>
        </ul>
      </div>

    </div>
  </div>

  <div class="card">
    <figure class="image">
      <img src="https://i.pinimg.com/564x/1b/43/3d/1b433d50a0c1d15eb02d25e88eb1fc11.jpg" alt="Nail art 2">
    </figure>
    <div class="overlay">
      <!--   Menu component  -->
      <div class="menu">
        <button tabindex=1 class="menu-toggle" style="anchor-name: --menu-toggle-2" popovertarget="menu-items-2">
          <span aria-hidden="true">➕</span>
          <span class="sr-only">open menu</span>
        </button>
        <ul class="menu-items" id="menu-items-2" popover style="position-anchor: --menu-toggle-2" role="menu">
          <li class="item">
            <button role="menuitem">
              <span aria-hidden="true">♥️</span>
              <span class="sr-only">add to favorites</span>
            </button>
          </li>
          <li class="item">
            <button role="menuitem">
              <span aria-hidden="true">💾</span>
              <span class="sr-only">save to collection</span>
            </button>
          </li>
          <li class="item">
            <button role="menuitem">
              <span aria-hidden="true">🔗</span>
              <span class="sr-only">copy link</span>
            </button>
          </li>
          <li class="item">
            <button role="menuitem">
              <span aria-hidden="true">✉️</span>
              <span class="sr-only">email</span>
            </button>
          </li>
          <li class="item">
            <button role="menuitem">
              <span aria-hidden="true">🛒</span>
              <span class="sr-only">add to cart</span>
            </button>
          </li>
          <li class="item">
            <button popovertargetaction="hide" popovertarget="menu-items-2" class="hidden-close">
              <span aria-hidden="true"> </span>
              <span class="sr-only">close menu</span>
            </button>
          </li>
        </ul>
      </div>
    </div>
  </div>
      
  <div class="card">
    <figure class="image">
      <img src="https://i.pinimg.com/564x/1f/c4/3f/1fc43fb2e79cb66688a32f784bd13e96.jpg" alt="Nail art 3">
    </figure>
    <div class="overlay">
      <!--   Menu component  -->
      <div class="menu">
        <button tabindex=1 class="menu-toggle" style="anchor-name: --menu-toggle-3" popovertarget="menu-items-3">
          <span aria-hidden="true">➕</span>
          <span class="sr-only">open menu</span>
        </button>
        <ul class="menu-items" id="menu-items-3" popover style="position-anchor: --menu-toggle-3" role="menu">
          <li class="item">
            <button role="menuitem">
              <span aria-hidden="true">♥️</span>
              <span class="sr-only">add to favorites</span>
            </button>
          </li>
          <li class="item">
            <button role="menuitem">
              <span aria-hidden="true">💾</span>
              <span class="sr-only">save to collection</span>
            </button>
          </li>
          <li class="item">
            <button role="menuitem">
              <span aria-hidden="true">🔗</span>
              <span class="sr-only">copy link</span>
            </button>
          </li>
          <li class="item">
            <button role="menuitem">
              <span aria-hidden="true">✉️</span>
              <span class="sr-only">email</span>
            </button>
          </li>
          <li class="item">
            <button role="menuitem">
              <span aria-hidden="true">🛒</span>
              <span class="sr-only">add to cart</span>
            </button>
          </li>
          <li class="item">
            <button popovertargetaction="hide" popovertarget="menu-items-3" class="hidden-close">
              <span aria-hidden="true"> </span>
              <span class="sr-only">close menu</span>
            </button>
          </li>
        </ul>
      </div>
    </div>
  </div>
</div>

              
            
!

CSS

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

.card {
  border-radius: 2rem;
  overflow: hidden;
  position: relative;
  max-width: 250px;
  height: max-content;
}

img {
  width: 100%;
  scale: 1.05;
}

.card {
  &:focus,
  &:hover,
  &:focus-within {
    .overlay {
      opacity: 1;
    }
  }
}

.overlay {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  background: rgb(0 0 0 / 0.4);
  opacity: 0;
  transition: opacity 0.25s;
}

.menu {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
}

/* import button */

: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 {
  justify-self: anchor-center;
  inset-area: center;
  /*  popover override  */
  inset: auto;
  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 demo, 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: #eee;
  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;
}

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

/* etc */

body {
  height: 100dvh;
}

.container {
  display: flex;
  gap: 2rem   
}
              
            
!

JS

              
                
              
            
!
999px

Console