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="container">
  <p class="subtitle">GreenSock</p>
  <h1 class="title">Stagger</h1>
  <div class="buttons-wrapper">
    <button id="restart-button">Restart</button>
    <button id="reverse-button">Hide</button>
  </div>
  <div class="flex-container">
    <div class="card">
      <div class="card__wrapper">
        <img src="https://images.unsplash.com/photo-1532344110095-8c22cdcfc71c?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=676&q=80" alt="leaf">
        <div class="card__text">
          <div>
            <h2>Consectetur adipiscing elit</h2>
            <p>
              In fermentum posuere urna nec tincidunt.
              Ultricies lacus sed turpis tincidunt id
              aliquet risus feugiat.
            </p>
          </div>
          <a href="">Learn more</a>
        </div>
      </div>
    </div>
    <div class="card">
      <div class="card__wrapper">
        <img src="https://images.unsplash.com/photo-1619589690392-31f74fd21ac5?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=676&q=80" alt="Waves breaking near the beach
">
        <div class="card__text">
          <div>
            <h2>Sed do eiusmod tempor</h2>
            <p>
              Nisi est sit amet facilisis magna etiam tempor.
              Turpis cursus in hac habitasse platea dictumst
              quisque sagittis.
            </p>
          </div>
          <a href="">Learn more</a>
        </div>
      </div>
    </div>
    <div class="card">
      <div class="card__wrapper">
        <img src="https://images.unsplash.com/photo-1619776391673-58f38f291197?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=700&q=80" alt="blue flower in tilt shift lens">
        <div class="card__text">
          <div>
            <h2>Incididunt ut labore</h2>
            <p>
              Quis ipsum suspendisse ultrices gravida dictum
              fusce ut placerat orci. Facilisis sed odio
              morbi quis commodo odio.
            </p>
          </div>
          <a href="">Learn more</a>
        </div>
      </div>
    </div>
  </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: 100vh;
  background: indigo;
  color: #fff;
}

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

.buttons-wrapper {
  margin-bottom: 24px;
}

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

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

.flex-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  /*   gap: 16px; */
}

.card {
  color: #000;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  max-width: 360px;
  width: calc(100% / 3 - 12px);
  opacity: 0;
  display: flex;
}

.card__wrapper {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.card img {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
}

.card h2 {
  margin-top: 0;
}

.card__text {
  flex-grow: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

              
            
!

JS

              
                const restartButton = document.getElementById("restart-button");
const reverseButton = document.getElementById("reverse-button");

const tween = gsap.fromTo(
  ".card",
  { opacity: 0, y: 100 },
  { opacity: 1, y: 0, duration: 1, stagger: 0.3 }
);

// play, pause, resume, reverse, restart
restartButton.addEventListener("click", () => {
  tween.restart();
});
reverseButton.addEventListener("click", () => {
  tween.reverse();
});

              
            
!
999px

Console