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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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>
    <div class="grid-12 trigger1">
        <h2 class="position-h2">The custom OLED displays on iPhone&nbsp;X deliver the most accurate color in the industry, HDR, and true blacks. And iPhone&nbsp;XMax has our largest display ever on an&nbsp;iPhone.</h2> 
    </div>
</section>
        
<section id = "pinMe">
    <div class="trigger2">
        <div class="iphone-image-wrapper">
            <div class="iphone1-text">
                <p>iPhone Xs Max</p>
                <p>6.5" dsiplay</p>
            </div>
            <div class="iphone-image iphone1">
                <div class="inner-phone"> 
                <img class="iphone1-img" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/2479807/iphone-1.png" alt=""> 
                <img class="iphone-stick" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/2479807/iphone-3.png" alt=""> 
                <img class="iphone1-img-behind" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/2479807/iphone-left.png" alt=""> </div>
            </div>
            <div class="iphone-image iphone2">
                <div class="inner-phone"> 
                <img class="iphone2-img" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/2479807/iphone-1.png" alt=""> 
                <img class="iphone2-img-behind" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/2479807/iphone-right.png" alt=""> 
                </div>
            </div>
            <div class="iphone2-text">
                <p>iPhone Xs Max</p>
                <p>5.8" display</p>
            </div>
        </div>
    </div>
</section>

<section>
    <div class="section3 grid-12 trigger3">
        <h2 class="position-h2">This section should come after and not overlap</h2> 
    </div>
</section>


              
            
!

CSS

              
                * {
  margin:0;
  padding:0;
}

* {
    box-sizing: border-box;
}

body {
    background: #000;
  overflow-x: hidden;
}

section {
    position: relative;
    height: 100vh;
    width: 100vw;
}

h2 {
    font-size: 35px;
    font-family: "SF Pro Display","SF Pro Icons","Helvetica Neue","Helvetica","Arial",sans-serif;
    font-weight: 500;
    color: #ffe5db;
}

.grid-12 {
    height: 100%;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: repeat(12, 1fr);
}

.position-h2 {
    grid-row: 7;
    grid-column: 4 / span 6;
    align-self: center;
}

.iphone-image-wrapper {
    height: 100vh;
    width: 100%;
    justify-content: center;
    display: grid;
    grid-auto-columns: 2fr 1fr 2fr;
    grid-template-rows: repeat(1, 1fr);
    align-items: center;
}

.iphone-image {
    grid-row: 1;
    grid-column: 2 / span 1;
    align-self: center;
    justify-self:center;
    text-align: center;
    max-width: 100%;
}

.inner-phone {
    position: relative;
}


p {
    color: #FFF;
    font-weight: 600;
    font-size: 20px;
    margin:0 0 8px 0;
}

.iphone1-text {
    grid-column: 1;
    text-align: right;
}

.iphone2-text {
    grid-column: 3;
}

.iphone1-img {
 position: absolute;
    z-index: 2;
}

.iphone-stick {
    display: none;
     position: absolute;
    left: 54.5%;
}

.iphone2-img {
 position: absolute;
    z-index: 2;
}

.iphone1 img {
    width: 100%;
}

.iphone2 img {
    width: 88%;
}

.iphone1-img-behind {
    z-index: 1;
    position: relative;
}

.iphone2-img-behind {
    z-index: 1;
    position: relative;
}





              
            
!

JS

              
                const controller = new ScrollMagic.Controller();
const tlFirstScroll = new TimelineMax();
const tlSecondScroll = new TimelineMax();

//First scroll scene
tlFirstScroll
  .set(".iphone-image-wrapper", { scale: 4, transformOrigin: "center top" })
  .to(".iphone-image-wrapper", 3, {
    scale: 2.2,
    y: "-50%"
  })
  .to(".iphone-image-wrapper", 3, {
    scale: 1,
    y: "0%"
  });

//Second scroll scene
tlSecondScroll
  .to(".iphone1", 3, { x: "-50%" })
  .to(".iphone2", 3, { x: "50%" }, "-=3")
  .from(".iphone1-text", 0.3, { autoAlpha: 0 }, "-=3")
  .from(".iphone2-text", 0.3, { autoAlpha: 0 }, "-=3")
  .to(".iphone1-text", 3, { x: "-30%" }, "-=3")
  .to(".iphone2-text", 3, { x: "30%" }, "-=3")

  .set(".iphone-stick", { display: "block" })
  .to(".iphone1-img-behind", 3, { x: "-50%" })
  .to(".iphone2-img-behind", 3, { x: "50%" }, "-=3")
  .to(".iphone1-img", 0.3, { autoAlpha: 0 }, "-=3")
  .to(".iphone2-img", 0.3, { autoAlpha: 0 }, "-=3")
  .to(".iphone1-text", 1, { autoAlpha: 0 }, "-=3")
  .to(".iphone2-text", 1, { autoAlpha: 0 }, "-=3");

//Scene 1
const sceneOne = new ScrollMagic.Scene({
  triggerElement: ".trigger1",
  triggerHook: 0,
  duration: "100%"
})
  .setTween(tlFirstScroll)
  .addIndicators()
  .addTo(controller);

const sceneTwo = new ScrollMagic.Scene({
  triggerElement: "#pinMe",
  triggerHook: 0,
  duration: "100%"
})
  .setTween(tlSecondScroll)
  .setPin("#pinMe")
  .addIndicators()
  .addTo(controller);

              
            
!
999px

Console