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="page">
  <header class="header">
    <div class="container">
      <div class="header-wrapper">
        <div class="logo">Logo</div>
        <button id="open-navbar" class="icon-button">
          <i class="fas fa-bars"></i>
        </button>
      </div>
    </div>
  </header>
  <main class="main">
    <div class="container">
      <p class="subtitle">GreenSock</p>
      <h1 class="title">
        Navbar
      </h1>
      <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Reiciendis necessitatibus et ab molestias impedit. Beatae, enim commodi, iste totam voluptatem doloribus quidem molestias eius nihil repudiandae pariatur ducimus.</p>
      <h2>Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel?</h2>
      <ul>
        <li>Lorem ipsum dolor sit amet consectetur.</li>
        <li>Esse harum saepe laborum similique nemo.</li>
        <li>Iure mollitia odit eaque necessitatibus quibusdam!</li>
        <li>Assumenda aperiam sunt nobis beatae. Iste.</li>
        <li>Nobis quisquam dolor temporibus aliquid ut.</li>
        <li>Quibusdam corrupti rerum commodi mollitia possimus!</li>
        <li>Autem repellat et a explicabo impedit!</li>
      </ul>
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dicta minus nisi laudantium, sunt, facere dolor dolorum ratione numquam sint iste aut. Excepturi totam blanditiis optio libero, doloremque eum molestias nostrum.</p>
      <p>Aliquid optio, tenetur, iste quae ducimus distinctio sit reprehenderit in nostrum corrupti adipisci exercitationem quo sed. Inventore sit, mollitia ipsam commodi veritatis aliquid molestias modi sint itaque corporis et possimus.</p>
      <p>Odit error magnam nostrum architecto? Dicta dolorum ea dignissimos ipsa placeat sint quas praesentium ad beatae deleniti amet officiis vel qui, quo sed tempore delectus, ab, ratione at corporis temporibus!</p>
    </div>
  </main>
</div>
<div id="navbar-wrapper" class="navbar-wrapper">
  <div id="navbar" class="navbar">
    <button id="close-navbar" class="icon-button icon-button_close">
      <i class="fas fa-times"></i>
    </button>
    <h2>
      Debitis natus
    </h2>
    <h3>Saepe voluptatibus</h3>
    <ul>
      <li><a href="">Lorem ipsum</a></li>
      <li><a href="">Consequatur facere</a></li>
      <li><a href="">Velit eum</a></li>
      <li><a href="">Tempore at</a></li>
    </ul>
    <h3>Error aliquam</h3>
    <ul>
      <li><a href="">Est corporis dolorum pariatur</a></li>
      <li><a href="">Numquam quia</a></li>
      <li><a href="">Sint aperiam minima</a></li>
      <li><a href="">Iste ad vitae aspernatur</a></li>
    </ul>
    <h3>Ullam officiis id esse</h3>
    <ul>
      <li><a href="">Lorem ipsum dolor</a></li>
      <li><a href="">Sint quia laborum</a></li>
    </ul>
  </div>
</div>
              
            
!

CSS

              
                *,
*::after,
*::before {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  font-family: sans-serif;
  font-size: 20px;
  line-height: 1.4;
  height: 100%;
}

.page {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.container {
  margin: 0 auto;
  padding: 0 24px;
  max-width: 80%;
  height: 100%;
}

main {
  flex: 1 0 auto;
  padding: 32px 0 64px 0;
  background: #ebebeb;
}

.header {
  height: 80px;
  flex-shrink: 0;
  color: #fff;
  background: indigo;
}

.header-wrapper {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  text-transform: uppercase;
  font-weight: bold;
  font-size: 24px;
}

.icon-button {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
}

.icon-button_close {
  color: indigo;
  position: absolute;
  right: 24px;
}

.title {
  margin-top: -12px;
}

.subtitle {
  margin: 0;
}

.navbar-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(75, 0, 130, 0.7);
  display: flex;
  justify-content: flex-end;
  transform: translateX(100%);
  clip-path: circle(0% at 100% 0);
}

.navbar {
  position: relative;
  width: 350px;
  background: #fff;
  padding: 24px;
  transform: translateX(100%);
  overflow-y: auto;
}

.navbar h2 {
  color: indigo;
  text-transform: uppercase;
  border-bottom: 4px solid indigo;
}

.navbar h3 {
  color: darkviolet;
  font-size: 0.9em;
  text-transform: uppercase;
}

.navbar ul {
  list-style-type: none;
  padding-left: 24px;
}

.navbar a {
  transition: color ease-in-out 0.3s;
  text-decoration: none;
}

.navbar a:hover {
  color: darkviolet;
}

              
            
!

JS

              
                import {
  disableBodyScroll,
  enableBodyScroll
} from "https://cdn.skypack.dev/body-scroll-lock";

const open = document.getElementById("open-navbar");
const close = document.getElementById("close-navbar");
const navbarWrapper = document.getElementById("navbar-wrapper");
const navbar = document.getElementById("navbar");

const timeline = gsap.timeline({ ease: "easeInOut", duration: 0.2 });

const animateOpenNavbar = () => {
  disableBodyScroll(navbarWrapper, { reserveScrollBarGap: true });

  timeline
    .set(navbarWrapper, { x: 0 })
    .to(navbarWrapper, { clipPath: "circle(150% at 100% 0)" })
    .to(navbar, { x: 0 });
};
const animateCloseNavbar = () => {
  enableBodyScroll(navbarWrapper);

  timeline
    .to(navbar, { x: "100%" })
    .to(navbarWrapper, { clipPath: "circle(0% at 100% 0)" })
    .set(navbarWrapper, { x: "100%" });
};

open.addEventListener("click", animateOpenNavbar);
close.addEventListener("click", animateCloseNavbar);
navbarWrapper.addEventListener("click", (e) => {
  if (e.target.className !== "navbar-wrapper") return;

  animateCloseNavbar();
});

              
            
!
999px

Console