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

              
                <div class="spacer"></div> <!-- Container before the splitscreen -->

<div id="wrapper">
  <div class="container left">
    <div id="bgImage"></div>
  </div>
  <div class="container right">
    <div class="message" id="message1">Message 1</div>
    <div class="message" id="message2">Message 2</div>
    <div class="message" id="message3">Message 3</div>
  </div>
</div>

<div class="spacer"></div> <!-- Container after the splitscreen -->
              
            
!

CSS

              
                body,
html {
  margin: 0;
  padding: 0;
}

.spacer {
  height: 100vh;
  background-color: #d0d0d0;
}

#wrapper {
  display: flex;
  height: 300vh;
}

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

.left #bgImage {
  background: url("https://images.pexels.com/photos/3222686/pexels-photo-3222686.jpeg")
    no-repeat bottom center;
  background-size: cover;
  width: 100%;
  height: 300%;
  position: absolute;
  transform-origin: center center;
  transform: scale(3);
}

.right .message {
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  opacity: 0;
  position: absolute;
  top: 0;
  left: 0;
}

              
            
!

JS

              
                gsap.registerPlugin(ScrollTrigger);

// Scaling down and pinning the background image on the left
gsap.to("#bgImage", {
  scale: 1,
  scrollTrigger: {
    trigger: ".left",
    pin: true,
    start: "top top",
    end: "+=200%",
    scrub: true
  }
});

// Fading in the messages on the right
const messages = gsap.utils.toArray(".message");
messages.forEach((message, index) => {
  gsap
    .timeline({
      scrollTrigger: {
        trigger: message,
        start: `top+=${index * 100}vh top`,
        end: `+=100vh`,
        pin: true,
        pinSpacing: "none",
        scrub: true
      }
    })
    .fromTo(message, { opacity: 0 }, { opacity: 1, duration: 0.5 }, "start") // Fades in the message
    .fromTo(message, { opacity: 1 }, { opacity: 0, duration: 0.5 }, "end-=0.5"); // Fades out the message
});

              
            
!
999px

Console