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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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 id="container"> 

<div class="panel blue">
  <div class="text text1">
   One 
  </div>
  <div class="text text2">
  Two
  </div>
  <div class="text text3">
  Three
  </div>
</div>

<div class="panel grey">
      <div id="para-text">
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
      </div>
</div>
   

</section>

  <section class="content">
    <h1>Content outside of layered pinning</h1>
  </section>  
  
  
 
              
            
!

CSS

              
                body {
  padding: 0;
  margin: 0;
}

@font-face {
    font-family: 'Monument';
    src: url('https://assets.codepen.io/4086427/MonumentExtended-Bold.otf');
 }
@font-face {
    font-family: 'Rational';
    src: url('https://assets.codepen.io/4086427/Rene+Bieder+-+RationalDisplayDEMO-SemiBold.otf');
 }
@font-face {
    font-family: 'Rational-light';
    src: url('https://assets.codepen.io/4086427/RationalDisplay-Light.otf');
 }

#container {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

.panel {
  width: 100%;
  height: 100vh;
  position: absolute;
  will-change: transform;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 900;
}
.panel.blue {
  background: blue;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  width: 100%;
  padding: 0;
}

.panel.grey {
  background: grey;

}
.text {
  position: absolute;
  margin: auto;
  font-family:"Monument";
  font-size: 5vw;
  opacity: 1;
  color: white;
}

#para-text {
  height:80vh;
  top:40vh;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align:left;
  left: 50px;
  max-width: 800px;
  font-size:36px;
  line-height: 1;
  font-family:sans-serif;
  color: black;
  opacity: 1;
}

section.content {
  position: relative;
  height:100vh;
  background-color:teal;
  color:#fff;
  display: flex; 
  flex-direction: column;
  align-items: center;
  justify-content: space-around;
}

              
            
!

JS

              
                gsap.registerPlugin(ScrollTrigger);

  
let tl = gsap.timeline({
  scrollTrigger: {
    trigger: "#container",
    start: "top top",
    end: "+=200%",
    scrub: true,
    pin: true,
    pinSpacing: true
  }
});

// Title switching NEW

gsap.utils.toArray(".text").forEach((el, i) => {  
  tl.to(el, {
    ease: "none",
    opacity: 0,
  }, el.id); // use element id for label
});


/*
// Title switching (old)

let stayTime = 1; // seconds between each text flip on the timeline (not literally seconds on screen - we're just spacing them out on the timeline)
let textElements = gsap.utils.toArray(".text"); // get an Array of all the ".text" elements

// loop through each text element and add an autoAlpha flip at the appropriate times on the timeline
textElements.forEach((el, i) => {
  tl.set(el, {autoAlpha: 1}, i * stayTime);
  if (i !== 0) { // if it's the first one, we don't need to toggle the previous one off.
    tl.set(textElements[i - 1], {autoAlpha: 0}, i * stayTime);
  }
});
// add some space at the end of the timeline so the last one stays for the correct duration before things get unpinned.
tl.set({}, {delay: stayTime});

*/

gsap.utils.toArray(".panel:not(:last-child)").forEach((el, i) => {  
  tl.to(el, {
    ease: "none",
    yPercent: -100
  }, el.id); // use element id for label
});

tl.to("#para-text", {opacity: 0,});





gsap.set(".panel", {zIndex: (i, target, targets) => targets.length - i});


              
            
!
999px

Console