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

              
                <section class="fs-l-513">
  <div class="container">
    <div class="content">
      <div class="wrapper-sticky">
        <strong>
          Example
        </strong>
        <h2>
          Youtube Shorts
        </h2>
        <p>
          Quick hits from one of the friendliest folks in CSS.
        </p>

        <ul class="images-content" id="gsapImagesContent">
          <li>
            <h3>
              Underused CSS Features
            </h3>
            <p>
              overscroll-behavior: contain is super useful, has great browser support, and yet a lot of people aren't even aware of it!
            </p>
            <iframe class="hide-at-full" width="315" height="560"
src="https://www.youtube.com/embed/FbV4M_ynSi0"
title="YouTube video player"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowfullscreen></iframe>
          </li>
          <li>
            <h3>
              Scroll-based animations
            </h3>
            <p>
              Scroll-based animations with CSS are incredibly powerful AND super easy to use, can't ask for much more than that!
            </p>
            <iframe class="hide-at-full" width="315" height="560"
src="https://www.youtube.com/embed/5DfWwzzsuoE"
title="YouTube video player"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowfullscreen></iframe>
          </li>
          <li>
            <h3>
              Daily Dev
            </h3>
            <p>
              Sponsor for Kevin, but just a helpful resource to me. Check out daily dev to keep up with CSS, and all topics front-end related! <a href="https://daily.dev/kevin-powell">https://daily.dev/kevin-powell</a>
            </p>
            <iframe class="hide-at-full" width="315" height="560"
src="https://www.youtube.com/embed/45PE03Ca1Lg"
title="YouTube video player"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowfullscreen></iframe>
          </li>
          <li>
            <h3>
              New ways to animate display
            </h3>
            <p>
              We used to have to come up with workarounds for animating and transitioning to and from display: none, but it's really easy to do now!
            </p>
            <iframe class="hide-at-full" width="315" height="560"
src="https://www.youtube.com/embed/owFsdm8q7rM"
title="YouTube video player"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowfullscreen></iframe>
          </li>
        </ul>
      </div>
    </div>
    <div class="show-at-full">
      <ul class="images" id="gsapImages">
        <li>
          <iframe width="315" height="560"
src="https://www.youtube.com/embed/FbV4M_ynSi0"
title="YouTube video player"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowfullscreen></iframe>
        </li>
        <li>
          <iframe width="315" height="560"
src="https://www.youtube.com/embed/5DfWwzzsuoE"
title="YouTube video player"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowfullscreen></iframe>
        </li>
        <li>
          <iframe width="315" height="560"
src="https://www.youtube.com/embed/45PE03Ca1Lg"
title="YouTube video player"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowfullscreen></iframe>
        </li>
        <li>
          <iframe width="315" height="560"
src="https://www.youtube.com/embed/owFsdm8q7rM"
title="YouTube video player"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowfullscreen></iframe>
        </li>
      </ul>
    </div>
  </div>
</section>
              
            
!

CSS

              
                .content {
  margin-inline: auto;
  max-width: 600px;
  padding-block: 2rem;
}

.fs-l-513 {
  padding-inline: 1rem;
}

.images-content {
  margin-block-start: 4rem;
}

.show-at-full {
  display: none;
}

@media screen and (min-width: 768px) {
  .container {
    display: grid;
    gap: 2rem;
    grid-template-columns: 1fr 1fr;
    max-inline-size: 1280px;
    margin-inline: auto;
  }
  
  .content {
    margin-inline: 0;
    max-inline-size: auto;
    padding-block-start: 4rem;
  }
  
  .hide-at-full {
    display: none;
  }
  
  .images {
    padding-bottom: 4rem;
  }
  
  .images li img {
    margin-block-start: 5rem;
  }
  
  .images-content {
    display: grid;
  }
  
  .images-content li {
    grid-column-start: 1;
    grid-row-start: 1;
  }
  
  .images-content li:not(:first-child) {
    opacity: 0;
    pointer-events: none; 
  }
  
  .show-at-full {
    display: block;
  }
  
  .wrapper-sticky {
    position: sticky;
    top: 4rem;
  }
}

/* Content Styles */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap');

:root {
  --color-bg: #fff;
  --color-text: #000;
  --color-heading: #000;
}

a {
  color: #ff0000;
}

a:active, a:focus, a:hover {
  opacity: 0.5;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: "Roboto", sans-serif;
  font-weight: 400;
  font-style: normal;
  font-size: clamp(1rem, 0.925rem + 0.32vw, 1.125rem);
  line-height: 1.5;
  margin: 0;
}

pre {
  background-color: var(--color-bg-code);
  box-shadow: var(--shadow);
  padding: 1rem;
  white-space: normal;
}

h2, h3 {
  color: var(--color-heading);
}

h2, h3, strong {
  font-weight: 700;
}

h2 {
  font-size: clamp(2.25rem, 1.8rem + 1.92vw, 3rem);
  line-height: 1.25;
  margin-block: 0.5rem;
}

h3 {
  font-size: clamp(1.25rem, 1.1rem + 0.64vw, 1.5rem);
  margin-block-end: 0;
  margin-block-start: 2rem;
}

img {
  box-shadow: var(--shadow);
}

iframe {
  margin-block-start: 2rem;
}

iframe {
  display: block;
  margin-inline: auto;
}

.link-button {
  align-items: center;
  border: 1px solid #000;
  display: inline-flex;
  color: #000;  
  justify-content: center;
  padding-inline: 1rem;
  padding-block: 0.5rem;
  text-decoration: none;
}

@media screen and (min-width: 768px) {
  h3 {
    margin-block-start: 0;
  }
}

/* Reset Styles */

* {
  box-sizing: border-box;
}

img {
  display: block;
  height: auto;
  max-inline-size: 100%;
}

ul, li {
  list-style: none;
  margin: 0;
  padding: 0;
}
              
            
!

JS

              
                gsap.registerPlugin(ScrollTrigger);

const imagesContentItems = document.querySelectorAll("#gsapImagesContent li");
const imagesItems = document.querySelectorAll("#gsapImages li");

gsap.matchMedia().add("(min-width: 768px)", function() {
  imagesItems.forEach((image, index) => {
    ScrollTrigger.create({
      trigger: image,
      start: "top center",
      end: "bottom center",
      onEnter: () => {
        gsap.to(imagesContentItems[index], { opacity: 1, y: 0, pointerEvents: "auto", duration: 0.5 });
      },
      onLeave: () => {
        gsap.to(imagesContentItems[index], { opacity: 0, y: -48, pointerEvents: "none", duration: 0.5 });
      },
      onEnterBack: () => {
        gsap.to(imagesContentItems[index], { opacity: 1, y: 0, pointerEvents: "auto", duration: 0.5 });
      },
      onLeaveBack: () => {
        gsap.to(imagesContentItems[index], { opacity: 0, y: 48, pointerEvents: "none", duration: 0.5 });
      },
    });
  });
});
              
            
!
999px

Console