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

              
                <div id="navigation-bar">
<div class="container d-flex flex-row">
      <a href="/#blue">Blue</a>
      <a href="/#squares">Squares</a>
      <a href="/#red">Red</a>
      <a href="/#purple">Purple</a>
      <a href="/#brown">Brown</a>
      <a href="/#orange">Orange</a>
    </div>
</div>


<div id="scrollWrap">
<section id="blue" class="section">
 
</section>
<section id="squares" class="section">
  
  <div class="middle">
    <div class="left">
      </p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent consectetur dolor ut dignissim suscipit. Ut ut nulla eu nunc laoreet pretium ac sit amet metus. Aliquam tristique porta sollicitudin. Vivamus blandit non lectus eget lobortis. Proin sed felis ac orci fermentum rhoncus vel vitae libero. Suspendisse non mauris leo. Pellentesque at consequat massa. </p>
    </div>
    <div class="right">
      <img src="https://via.placeholder.com/300" class="square mb-5" />
    <img src="https://via.placeholder.com/300" class="square mb-5" />
  <img src="https://via.placeholder.com/300" class="square mb-5" />
<img src="https://via.placeholder.com/300" class="square mb-5" />
<img src="https://via.placeholder.com/300" class="square mb-5" />
  </div>
</div>
  
</section>
<section id="red" class="section">
  
</section>
</div>
<section id="purple" class="section"></section>
<section id="brown" class="section"> </section>
<section id="orange" class="section"> </section>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Signika+Negative:300,400&display=swap');

body { 
  font-family: "Signika Negative", sans-serif; 
  font-weight: 300;
  margin: 0;
  padding: 0 20px;
}

.section {
  height: 400px;
  overflow:hidden;
}

#blue {
  background-color: blue;
}
#squares {
  background-color: white;
}
#red {
  background-color: red;
}
#purple {
  background-color: purple;
}
#brown {
  background-color: brown;
}
#orange {
  background-color: orange;
}

.middle {
  display: flex;
  flex-direction: row;
  width:100%;
}
.left {
  width:30%;
}
.right {
  width: 70%;
  display:inline-flex;
  overflow:hidden;
}
.square {
  height: 300px;
  padding: 20px;
}

#navigation-bar {
  text-transform: uppercase;
  background-color: rgba(255,255,255, 0.86);
  z-index: 2;
  width: 100%;
  padding: 10px 0px;
  box-shadow:0 5px 5px -5px rgba(000,000,000,0.2);
  position: sticky;
  top: 0;
  padding-left: 35px;
  padding-right: 35px;
}

.d-flex {
    justify-content: space-between;
    align-items: center;
  }

.flex-row {
  flex-direction: row;
}
              
            
!

JS

              
                console.clear();

gsap.to('.square', { 
  scrollTrigger: {
    trigger: "#scrollWrap",
    pin: true,   // pin the trigger element while active
    start: "center center", // when the top of the trigger hits the top of the viewport
    end: "+=850", // end after scrolling 500px beyond the start
    // markers: {startColor: "red", endColor: "red", fontSize: "18px", fontWeight: "bold", indent: 20},
    pinSpacing: true,
    fastScrollEnd: true,
    scrub: 1, // smooth scrubbing, takes 1 second to "catch up" to the scrollbar 
  },
  x: -925
});

                
gsap.utils.toArray("#navigation-bar a").forEach(function(a) {
  let wrap = document.querySelector("#scrollWrap"),
      triggerEl = document.querySelector(a.getAttribute("href").substring(1)),
      st = ScrollTrigger.create({
            trigger: triggerEl,
            pinnedContainer: wrap.contains(triggerEl) ? wrap : null,
            start: "top 40"
          });
  a.addEventListener("click", function(e) {
    e.preventDefault();
    console.log("animate to", e.target.getAttribute("href"));
    gsap.to(window, {
      duration: 1,
      scrollTo: {
        y: st.start, 
      }
    });
  });
});

//ScrollTrigger.sort();
              
            
!
999px

Console