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="content">
      <header>
        <h1>Popover Sliding Nav</h1>
        <button popovertarget=menu>
          <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
            <path stroke-linecap="round" stroke-linejoin="round" d="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5" />
          </svg>
          <span class="sr-only">Toggle Menu</span>
        </button>
      </header>
      <main>
        <p>Jus' because the name is "Popover", it doesn't have to be a stereotypical popover.</p>
        <p>You could make a sliding menu that contains a nav. And then you can take advantage of light-dismiss, etc.</p>
        <p>You could even translate the body when you open it up.</p>
        
      </main>
    </div>
    <div popover id="menu" role="menu">
      <svg viewBox="0 0 969 955" fill="none" xmlns="http://www.w3.org/2000/svg">
        <circle cx="161.191" cy="332.736" r="133.191" fill="none" stroke="var(--text-1)" stroke-width="20" />
        <circle cx="806.809" cy="332.736" r="133.191" fill="none" stroke="var(--text-1)" stroke-width="20" />
        <circle class="eye" cx="695.019" cy="600.278" r="31.4016" fill="var(--text-1)" />
        <circle class="eye" cx="272.981" cy="600.278" r="31.4016" fill="var(--text-1)" />
        <path d="M564.388 724.628C564.388 756.538 526.035 792.455 483.372 792.455C440.709 792.455 402.356 756.538 402.356 724.628C402.356 692.717 440.709 676.897 483.372 676.897C526.035 676.897 564.388 692.717 564.388 724.628Z" fill="var(--text-1)" />
        <rect x="310.42" y="460.854" width="343.468" height="51.4986" fill="#FF1E1E" />
        <path fill-rule="evenodd" clip-rule="evenodd" d="M745.643 300.784C815.368 356.729 854.539 445.167 854.539 524.286H614.938V467.196C614.938 445.657 597.477 428.196 575.938 428.196H388.37C366.831 428.196 349.37 445.657 349.37 467.196V524.286L110.949 524.286C110.949 445.167 150.12 356.729 219.845 300.784C289.57 244.839 384.138 213.41 482.744 213.41C581.35 213.41 675.918 244.839 745.643 300.784Z" fill="var(--text-1)" />
      </svg>
      <nav>
        <a autofocus href=/home><span>Home</span></a>
        <a href=/contact><span>Contact</span></a>
        <a href=/showcase><span>Showcase</span></a>
        <a href=/blog><span>Blog</span></a>
        <a href=/about><span>About</span></a>
      </nav>
    </div>
              
            
!

CSS

              
                @import "https://unpkg.com/open-props/open-props.min.css";
@import "https://unpkg.com/open-props/normalize.min.css";

* {
  box-sizing: border-box;
}

pre {
  background: black;
  color: hsl(10 90% 60%);
  font-weight: bold;
  width: 100%;
  max-inline-size: 100%;
  padding: 1rem;
}

:root {
  --padding: 1rem;
  --transition: 0.165s;
}

body {
  min-height: 100vh;
  width: 100vw;
  background: var(--surface-1);
}

nav {
  display: grid;
  text-transform: uppercase;
  gap: 0.5rem;
}

[popover] {
  overflow: hidden;
}

.eye {
  transform-box: fill-box;
  transform-origin: center;
  scale: 1;
  animation: blink 8s infinite linear;
}

@keyframes blink {
  0%, 46%, 48%, 50%, 100% {
    transform: scaleY(1);
  }
  47%, 49% {
    transform: scaleY(0.01);
  }
}

main {
  display: grid;
  align-items: center;
  gap: 1rem;
}

a:is(:hover, :focus-visible) span {
  translate: 1ch 0;
}
a:is(:hover, :focus-visible):after {
  scale: 1 1;
}
a span {
  display: inline-block;
  transition: translate 0.2s;
}
a:after {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  translate: 0 -50%;
  height: 4px;
  width: 0.8ch;
  background: red;
  transition: scale 0.2s;
  scale: 0 1;
  transform-origin: 0 50%;
}

svg {
  width: 48px;
  z-index: 2;
}

#menu {
  background: white;
  margin: 0;
  padding: 1rem;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  position: fixed;
  inset: unset;
  top: 0;
  left: 100%;
  height: 100vh;
  width: 220px;
  border-radius: 0;
  transition: display 0.2s, overlay 0.2s, translate 0.2s;
  translate: calc(var(--open, 0) * -100%) 0;
}

[popovertarget] {
  background: transparent;
  color: var(--text-1);
}

[popovertarget] svg {
  stroke-width: 2;
  stroke: var(--text-1);
}

a {
  padding: 0.25rem;
  color: var(--text-2);
  font-size: 1.5rem;
  text-decoration: none;
  position: relative;
}

a:focus-visible {
  outline-color: var(--red-6);
}

[popovertarget] {
  position: fixed;
  top: 1rem;
  right: 1rem;
  inline-size: 48px;
  aspect-ratio: 1;
}

[popovertarget]:is(:hover, :focus-visible) {
  background: var(--surface-2);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
.content {
  padding-top: 4rem;
  display: grid;
  place-items: center;
  align-content: start;
  transition: translate 0.2s;
}

h1 {
  margin-bottom: 2rem;
}

body:has(#menu:popover-open) .content {
  translate: -220px 0;
}

#menu::backdrop {
  background: hsl(0 0% 85% / 0.5);
  backdrop-filter: blur(4px);
  opacity: var(--open, 0);
  transition: opacity 0.2s, display 0.2s, overlay 0.2s;
}

@media (prefers-color-scheme: dark) {
  #menu {
    background: black;
  }
  #menu::backdrop {
    background: hsl(0 0% 15% / 0.5);
  }
}

#menu:popover-open,
#menu:popover-open::backdrop {
  @starting-style {
    --open: 0;
  }
  --open: 1;
}

h1 {
  font-size: 3rem;
  font-weight: 900;
}

[popover] svg {
  position: absolute;
  bottom: 20%;
  right: 0rem;
  inline-size: 300px;
  translate: 50% 25%;
}
              
            
!

JS

              
                
              
            
!
999px

Console