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

              
                <body translate="no">
  <div class="app">
    <div class="title">GRID</div>
    <div class="gallery">

      <div class="originalContainer">
        <span id="vertical-l"></span>
        <span id="bottom"></span>
        <span id="vertical-r"></span>
      </div>

      <div class="originalContainer">
        <span id="vertical-r"></span>

      </div>

      <div class="originalContainer">
        <span id="vertical-r"></span>

      </div>

      <div class="originalContainer">
        <span id="vertical-r"></span>
      </div>

      <div class="originalContainer">
        <span id="bottom"></span>
      </div>

      <div class="originalContainer">
      </div>

      <div class="originalContainer">
      </div>

      <div class="originalContainer">
      </div>
      <div class="originalContainer">
      </div>
      <div class="originalContainer">
      </div>
      <div class="originalContainer">
      </div>

      <div class="originalContainer">
      </div>

    </div>
  </div>
</body>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css2?family=Nixie+One&display=swap");

html,
body {
  width: 100%;
  height: 100%;
  background: #efebe0;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.app {
  height: 100%;
  width: 40%;
  padding-top: 3.5%;
  display: block;
  /*position: relative;*/
  background: #efebe0;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;

  /* Hide the app on load */
  /* visibility: hidden;*/
}

/*
originalContainer {
  width: 100%;
}
*/

.gallery {
  max-width: 900px;
  max-height: 800px;
  margin: 0 auto;
  display: grid;
  gap: 0rem;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  grid-template-rows: repeat(auto-fit, minmax(150px, 1fr));
}

.title {
  font-family: "Nixie One";
  display: block;
  text-align: center;
  font-size: 5.5vw;
  padding-bottom: 20px;
  z-index: 50;
  color: #0177ff;
}

.originalContainer {
  border-right: 0px solid #0177ff;
  border-bottom: 0px solid #0177ff;
  margin: 0;
  padding: 0;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  position: relative;
}

.gallery div:nth-child(4n) {
  border-right: none;
}
.gallery div:nth-child(8) ~ div {
  border-bottom: none;
}

.item {
  cursor: pointer;
  font-size: 0;
}

.newContainer {
  position: absolute;
  top: 50%; /* position the top  edge of the element at the middle of the parent */
  left: 50%; /* position the left edge of the element at the middle of the parent */
  transform: translate(-50%, -50%);
  width: 300px;
  height: 300px;
  z-index: 1;
  visibility: hidden;
}

.newContainer > * {
  margin-bottom: 1rem;
}

.detail .title {
  font-size: 2rem;
  text-transform: uppercase;
}

.detail .secondary {
  color: lightgray;
}

.detail .description {
  line-height: 1.5;
}
.box {
  height: 100%;
  width: 100%;
}

.fixed {
  top: 5%;
  left: 5%;
  position: fixed;
  width: 90%;
  height: 90%;
  border: solid 1px #0177ff;
  z-index: 999;
}

#bottom {
  position: absolute;
  background: none transparent;
  bottom: 0;
  left: 0;
  width: 200px;
  height: 1px;
  z-index: 1;
}

#vertical-r {
  position: absolute;
  background: none transparent;
  right: 0;
  top: 0;
  height: 200px;
  width: 1px;
  z-index: 1;
}

#vertical-l {
  position: absolute;
  background: none transparent;
  left: 0;
  top: 0;
  height: 200px;
  width: 1px;
  z-index: 1;
}

              
            
!

JS

              
                // set initial state
gsap.set("#bottom", { backgroundColor: "#0177FF", width: 0 });
gsap.set("#vertical-r, #vertical-l", { height: 0, backgroundColor: "#0177FF" });
gsap.set(".lottieHolder", { autoAlpha: 0 });

let gridTL; // store the timeline in an external variable so it persists and we can kill() it before recreating a new one.

function drawGrid() {
  let gridWidth = gsap.getProperty(".gallery", "width", "px");
  let gridHeight = gsap.getProperty(".gallery", "height", "px");
  gridTL && gridTL.kill();

  gridTL = gsap.timeline();

  gridTL.to("#bottom", {
    stagger: {
      amount: 0.2,
      ease: "power4"
    },
    width: gridWidth
  });

  gridTL.to(
    "#vertical-r, #vertical-l",
    {
      stagger: {
        amount: 0.5,
        ease: "power4"
      },
      height: gridHeight
    },
    ">-0.5"
  );

  gridTL.to(
    ".lottieHolder",
    {
      stagger: {
        amount: 1,
        ease: "power2"
      },
      autoAlpha: 1,
      duration: 2.75
    },
    ">-1"
  );
}

drawGrid();

window.addEventListener("resize", drawGrid);

              
            
!
999px

Console