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>
      </div>
    </div>
  </header>
  <main class="main">
    <div class="container">
      <p class="subtitle">GreenSock</p>
      <h1 class="title">
        Modal
      </h1>
      <p>
        Lorem ipsum, dolor sit amet consectetur adipisicing elit. Minima architecto quo repellat eos maxime quos recusandae delectus quibusdam odit inventore impedit cupiditate totam voluptates fuga adipisci, assumenda, nemo culpa voluptatum esse asperiores.
      </p>
      <button id="open-modal" class="button button_mb">Open modal</button>
      <h2>Lorem ipsum dolor sit amet consectetur.</h2>
      <p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Cum earum maxime tenetur incidunt iste non obcaecati sint veritatis consectetur eaque vero possimus, quidem nemo. Adipisci laborum eos vel eius sunt debitis accusantium aliquam et consequatur fugit, neque sed!</p>
      <p>Odit, recusandae reiciendis, ducimus repellendus impedit sed libero corporis soluta repudiandae laudantium praesentium suscipit maxime! Fugit voluptates odio iusto, rem exercitationem distinctio sit vel molestiae sed tenetur eaque. Quidem, omnis? Sunt iure aspernatur quasi porro ut nostrum distinctio.</p>
      <p>Expedita facere hic aliquid vel nisi, in officiis ipsam quo ab quisquam dignissimos quaerat iusto mollitia doloremque odit distinctio numquam officia enim? Sequi sapiente quasi, veniam deleniti voluptas beatae magnam suscipit, labore voluptatem sit deserunt earum quidem omnis.</p>
      <p>Sint pariatur aspernatur nobis voluptatum facilis dolorum quisquam, maxime beatae officia perferendis laborum accusantium libero explicabo quibusdam deserunt tempora nemo fuga possimus obcaecati. Iste enim porro totam eaque eius, cupiditate quisquam alias, debitis facilis commodi voluptatem provident autem?</p>
    </div>
  </main>
</div>
<div id="modal-wrapper" class="modal-wrapper">
  <div id="modal" class="modal">
    <h2>Hello there 👋</h2>
    <p>I hope you are doing well!</p>
    <button id="close-modal" class="button button_mt">Close modal</button>
  </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;
}

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

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

.subtitle {
  text-align: left;
  margin: 0;
}

.button {
  cursor: pointer;
  background: indigo;
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
}

.button_mb {
  margin-bottom: 64px;
}

.button_mt {
  margin-top: 24px;
}

.modal-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(75, 0, 130, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(100%);
  clip-path: circle(0% at 0 0);
  /*   opacity: 0; */
}

.modal {
  border-radius: 12px;
  background: #fff;
  width: 30%;
  min-width: 360px;
  padding: 24px;
  transform: translateY(20%);
  opacity: 0;
}

.modal h2 {
  margin: 0 0 24px 0;
}

              
            
!

JS

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

const open = document.getElementById("open-modal");
const close = document.getElementById("close-modal");
const modalWrapper = document.getElementById("modal-wrapper");
const modal = document.getElementById("modal");

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

const animateOpenModal = () => {
  disableBodyScroll(modalWrapper, { reserveScrollBarGap: true });

  timeline
    .set(modalWrapper, { y: 0 })
    .to(modalWrapper, { clipPath: "circle(150% at 0 0)" })
    .to(modal, { y: 0, opacity: 1 });
};
const animateCloseModal = () => {
  enableBodyScroll(modalWrapper);

  timeline
    .to(modal, { y: "20%", opacity: 0 })
    .to(modalWrapper, { clipPath: "circle(0% at 0 0)" })
    .set(modalWrapper, { y: "100%" });
};

open.addEventListener("click", animateOpenModal);
close.addEventListener("click", animateCloseModal);
modalWrapper.addEventListener("click", (e) => {
  if (e.target.className !== "modal-wrapper") return;

  animateCloseModal();
});

              
            
!
999px

Console