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

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

              
                 <section class="section-1">
      <h1 class="header-1">
        Header
      </h1>
      <div class="item-1">item 1
        <div class="item-description-1">
          item description 1
        </div>
      </div>
      <div class="item-2">item 2
        <div class="item-description-2">
          item description 2
        </div>
      </div>
      <div class="item-3">item 3
        <div class="item-description-3">
          item description 3
        </div>
      </div>
    </section>
    <section class="section-2">
      <h1 class="header-2">
        Header
      </h1>
      <p>content</p>
    </section>
    <section class="section-3">
      <h1 class="header-3">
        Header
      </h1>
      <p>content</p>
    </section>
              
            
!

CSS

              
                 * {
        margin: 0;
        padding: 0;
      }

      section {
        width: 100vw;
        height: 100vh;
        position: relative;
        text-align: center;
      }

      .section-1 {
        background-color: lightsteelblue;
      }

      .section-2 {
        background-color: cadetblue;
      }

      .section-3 {
        background-color: lightcyan;
      }

      h1 {
        padding: 30px;
        font-size: 32px;
        text-transform: uppercase;
      }

      .header-1 {
        position: absolute;
        top: 33%;
        left: 33%;
      }

      .item-1,
      .item-2,
      .item-3 {
        background-color: grey;
        width: 20vh;
        height: 80vh;
        position: absolute;
        bottom: 0;
        left: -15vw;
      }

      .item-2 {
        left: 50vw;
      }

      .item-3,
      .item-4 {
        left: 100vw;
      }

      .item-description-1,
      .item-description-2,
      .item-description-3 {
        opacity: 0;
        background-color: #dbdbdb;
        padding: 10px;
        position: absolute;
        top: 50%;
        left: 33%;
      }
              
            
!

JS

              
                
      gsap.registerPlugin(ScrollTrigger);

      const TL_intro = gsap.timeline({

        scrollTrigger: {
          trigger: '.header-1',
          start: 'top 20%',
          end: 'bottom 30%',
          scrub: 1,
          markers: true,
          pin: true
        }
      });
      TL_intro.to('.header-1', {
        autoAlpha: 0,
      })


      const TL_items = gsap.timeline({
        scrollTrigger: {
          trigger: ".section-1",
          scrub: 1,
          start: "top top",
          end: "+=300%",
          markers: true,
          pin: true,
        }
      });

      TL_items.to('.item-2', {
        x: '23vw', //slide in from left - out of view into view
        onComplete: () => {
          gsap.to('.item-description-1', {
            autoAlpha: 0
          })
        }
      })
        .to(".item-1", {
          x: '55vw', // slide to the right of screen - but not out of view
          ease: "power2",
          onComplete: () => {
            gsap.to('.item-description-1', {
              autoAlpha: 1 // fade in description when centre stage
            })
          }
        })
        .to('.item-2', {
          x: '0vw', // slide to centre
          onComplete: () => {
            gsap.to('.item-description-2', {
              autoAlpha: 1 // fade in description when centre stage
            })
          }
        })
        .to(".item-1", {
          x: '0vw', // slide to the right of screen
          ease: "power2",
          onUpdate: () => {
            gsap.to('.item-description-1', {
              autoAlpha: 0 // fade out description when not centre stage
            })
          }
        })
        .to('.item-2', {
          x: '-43vw', // slide to centre
          onUpdate: () => {
            gsap.to('.item-description-2', {
              autoAlpha: 0 // fade out description when not centre stage
            })
          }
        })
        .to(".item-3", {
          x: '-55vw', // slide in from out of view 
          ease: "power2",
          onComplete: () => {
            gsap.to('.item-description-3', {
              autoAlpha: 1 // fade in description when centre stage
            })
          }
        })
        .to(".item-2", {
          x: '-75vw', // slide in from out of view 
          ease: "power2",

        })
        .to(".item-3", {
          x: '-75vw', // slide in from out of view 
          ease: "power2",
          onComplete: () => {
            gsap.to('.item-description-3', {
              autoAlpha: 1 // fade in description when centre stage
            })
          }
        })
        .to(".item-3", {
          x: '-175vw', // slide in from out of view 
          ease: "power2",
          onUpdate: () => {
            gsap.to('.item-description-3', {
              autoAlpha: 0 // fade out description when not centre stage
            })
          }
        })

              
            
!
999px

Console