Pen Settings



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


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


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.


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.


                <h1 class="header-section">Scroll down to some different pinned content shown</h1>

<div class="container" style="margin-bottom: 100px;">
  <div class="col bg-grey" style="height: 300px; padding: 100px;">
    <h2>Here's some static content</h2>
  <div class="col">
    <img src="" alt="Static Image One" width="600" height="500" />

<div class="content-container">
  <div class="col left-content">
    <img id="img1" class="imageToShow" src="" alt="Image Number One" width="600" height="720" />
    <img id="img2" class="imageToShow" src="" alt="Image Number Two" width="600" height="720" />
    <img id="img3" class="imageToShow" src="" alt="Image Number Three" width="600" height="720" />
    <img id="img4" class="imageToShow" src="" alt="Image Number Four" width="600" height="720" />
    <img id="img5" class="imageToShow" src="" alt="Image Number Five" width="600" height="720" />
  <div class="col right-content">
    <div class="contentMarker" data-marker-content="img1">
      <h2 class="text-light">Text Number One</h2>
      <p class="text-light">Lorem ipsum dolor sit amet consectetur adipiscing elit.</p>
    <div class="contentMarker" data-marker-content="img2">
      <h2 class="text-light">Text Number Two</h2>
      <p class="text-light">Quis varius quam quisque id diam vel quam elementum.</p>
    <div class="contentMarker" data-marker-content="img3">
      <h2 class="text-light">Text Number Three</h2>
      <p class="text-light">Porta nibh venenatis cras sed felis eget velit.</p>
    <div class="contentMarker" data-marker-content="img4">
      <h2 class="text-light">Text Number Four</h2>
      <p class="text-light">Sed felis eget velit aliquet sagittis id.</p>
    <div class="contentMarker" data-marker-content="img5">
      <h2 class="text-light">Text Number Five</h2>
      <p class="text-light">Tristique senectus et netus et malesuada.</p>

<div class="container" style="margin-top: 100px;">
  <div class="col bg-grey" style="height: 150px; padding: 100px;">
    <h2>Here's some more static content</h2>
  <div class="col">
    <img src="" alt="Static Image Two" width="600" height="350" />


                body {
  margin: 0;
  font-family: sans-serif;

.header-section {
  text-align: center;
  margin: 40vh auto 50vh;

.container, .content-container {
  max-width: 1200px;
  width: 100%;
  margin-right: auto;
  margin-left: auto;
  display: flex;
  > .col {
    width: 50%;

.left-content {
  //height: 100vh;
  height: 720px;
  position: relative;
  > * {
    position: absolute;
    left: 50%;
    top: 50%;
    opacity: 0;
    visibility: hidden;

.right-content > * {
  background-color: #eeeeee;
  padding: 100px;
  height: 520px;
  display: flex;
  flex-direction: column;
  justify-content: center;

.bg-grey {
  background-color: #c4c4c4;

.contentMarker {
  border: 1px solid gray;



gsap.defaults({overwrite: 'auto'});

gsap.set(".left-content > *", {xPercent: -50, yPercent: -50});

// Set up our scroll trigger
const ST = ScrollTrigger.create({
    trigger: ".content-container",
    start: "top top",
    end: "bottom bottom",
    onUpdate: getCurrentSection,
    pin: ".left-content"

const contentMarkers = gsap.utils.toArray(".contentMarker");

// Set up our content behaviors
contentMarkers.forEach(marker => {
    marker.content = document.querySelector(`#${marker.dataset.markerContent}`);

    if(marker.content.tagName === "IMG") {
        gsap.set(marker.content, {transformOrigin: "center"});

        marker.content.enter = function() {
            gsap.fromTo(marker.content, {autoAlpha: 0}, {duration: 0.3, autoAlpha: 1});

    marker.content.leave = function() {, {duration: 0.1, autoAlpha: 0});


// Handle the updated position
let lastContent;
function getCurrentSection() {
    let newContent;
    const currScroll = scrollY;

    // Find the current section
    contentMarkers.forEach(marker => {
        if(currScroll > marker.offsetTop) {
            newContent = marker.content;

    // If the current section is different than that last, animate in
        && (lastContent == null
            || !newContent.isSameNode(lastContent))) {
        // Fade out last section
        if(lastContent) {

        // Animate in new section

        lastContent = newContent;


const media = window.matchMedia("screen and (max-width: 600px)");
ScrollTrigger.addEventListener("refreshInit", checkSTState);

function checkSTState() {
    if(media.matches) {
    } else {