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 id="hero">
  <h1>The Hero Section</h1>
  <p>Nullam gravida lacus quis elit interdum, ut dapibus lorem pulvinar. Nam mattis finibus lectus, id vulputate libero convallis vitae. Nulla ac suscipit libero. Quisque tristique dapibus augue, vel gravida neque aliquam ac. Nullam interdum egestas mauris nec tempus. Donec rhoncus, neque in viverra ullamcorper, augue nisi venenatis lorem, et scelerisque turpis diam et augue. Proin elementum blandit ligula vel fringilla.</p>
</div>

<div class="phone-container">
  <div id="phoneBorder"></div>
</div>
<div id="sectionTwo">
  <img class="respImg" src="https://images.unsplash.com/photo-1587365001066-8263b7061a38?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=2970&q=80" alt="">
</div>

<div id="animationContainer">

  <div class="info info1">
    <h2>A Short Title #1</h2>
    <img class="info-img" src="https://images.unsplash.com/photo-1548689572-a7eacaf43534?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=870&q=80" alt="">
    <ul>
      <li>List item number one.</li>
      <li>List item number two.</li>
      <li>List item number three.</li>
    </ul>
  </div>
  <div class="info info2">
    <h2>A Short Title #2</h2>
    <img class="info-img" src="https://images.unsplash.com/photo-1568682057239-760834b6ce63?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=774&q=80" alt="">
    <ul>
      <li>List item number one.</li>
      <li>List item number two.</li>
      <li>List item number three.</li>
    </ul>
  </div>
  <div class="info info3">
    <h2>A Short Title #3</h2>
    <img class="info-img" src="https://images.unsplash.com/photo-1583132169905-e2a585dbbb18?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=870&q=80" alt="">
    <ul>
      <li>List item number one.</li>
      <li>List item number two.</li>
      <li>List item number three.</li>
    </ul>
  </div>
</div><!-- /#animationContainer -->

<div id="footer">
  <h2>This is the footer section.</h2>
  <p>Our animation should not scroll into this area.</p>
</div>
              
            
!

CSS

              
                * {
  box-sizing: border-box;
}

body {
  margin: 0;
}

.phone-container {
  display: flex;
  justify-content: center;
  align-items: center;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  z-index: 100;
}

.respImg {
  width: 100%;
  height: auto;
}

#hero {
  color: white;
  background: #0f1010;
  text-align: center;
  padding: 8rem 5rem;
}

#sectionTwo {
  position: relative;
}

#animationContainer {
  position: relative;
  min-height: 100vh;
}

#phoneBorder {
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  border: 8px solid blue;
  height: 300px;
  width: 175px;
  opacity: 0;
  visibility: hidden;
}

.info {
  position: relative; // prog enhancement
  min-height: 100vh;
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  width: 100%;
  border: 2px dotted green;

  h2 {
    width: 25%;
  }

  .info-img {
    width: 175px;
    height: 300px;
    margin: 0 1rem;
  }

  ul {
    width: 25%;
    padding: 0;
    list-style-position: inside;
  }
}

.info1 {
  z-index: 1;
}
.info2 {
  z-index: 2;
}
.info3 {
  z-index: 3;
}

.info:nth-child(n + 2) {
  opacity: 0;
}

#footer {
  color: white;
  background-color: #0f1010;
  text-align: center;
  padding: 6rem 0;
}

              
            
!

JS

              
                console.clear();

gsap.registerPlugin(ScrollTrigger);

let phoneBorder = document.getElementById("phoneBorder");
let infos = gsap.utils.toArray(".info");
const hero = document.getElementById("hero");

gsap.set(infos, { position: "absolute" });

let tl = gsap.timeline({
  scrollTrigger: {
    trigger: "#animationContainer",
    pin: true,
    scrub: 0.5,
    start: "top top",
    end: "+=2000"
    //end: "bottom top"
  }
});

infos.forEach((info) => {
  tl.to(info, {
    opacity: 1,
    duration: 0.25
  });
  tl.to(info, {
    opacity: 0,
    duration: 0.1
  });
});
gsap.set(phoneBorder, {
  y: () => window.innerHeight,
  yPercent: -100,
});
gsap.to(phoneBorder, {
  yPercent: -50,
  autoAlpha: 1,
  scrollTrigger: {
    trigger: ".phone-container",
    pin: ".phone-container",
    pinSpacing: false,
    start: () => "top+=" + hero.clientHeight + " top",
    end: () => tl.scrollTrigger.end,
    markers: true
  }
});

              
            
!
999px

Console