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

              
                <section class="section-1">
  <h1 class="page-title">Happy Scrolling!</h1>
  <svg class="arrow" viewBox="0 0 320 512" width="100" title="angle-double-down">
    <path d="M143 256.3L7 120.3c-9.4-9.4-9.4-24.6 0-33.9l22.6-22.6c9.4-9.4 24.6-9.4 33.9 0l96.4 96.4 96.4-96.4c9.4-9.4 24.6-9.4 33.9 0L313 86.3c9.4 9.4 9.4 24.6 0 33.9l-136 136c-9.4 9.5-24.6 9.5-34 .1zm34 192l136-136c9.4-9.4 9.4-24.6 0-33.9l-22.6-22.6c-9.4-9.4-24.6-9.4-33.9 0L160 352.1l-96.4-96.4c-9.4-9.4-24.6-9.4-33.9 0L7 278.3c-9.4 9.4-9.4 24.6 0 33.9l136 136c9.4 9.5 24.6 9.5 34 .1z" />
  </svg>
</section>
<section class="section section-2">
  <div class="curtain">
  </div>
  <div class="text">
    FROM fairest creatures we desire increase,<br>
That thereby beauty's rose might never die...
  </div>
</section>
<section class="section section-3">
  <div class="curtain">
  </div>
  <div class="text">
But as the riper should by time decease,<br>
His tender heir might bear his memory:<br>
But thou, contracted to thine own bright eyes,<br>
Feed'st thy light'st flame with self-substantial fuel,...
  </div>
</section>
<section class="section section-4">
  <div class="curtain">
  </div>
  <div class="text">
Making a famine where abundance lies,<br>
Thyself thy foe, to thy sweet self too cruel.
  </div>
</section>
              
            
!

CSS

              
                *:before,
*:after,
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  font-family: Montserrat, sans-serif;
  font-weight: 400;
  color: #333;
}

section {
  padding: 2em;
  height: 100vh;
  border-bottom: 2px solid rgb(245, 245,66);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.section-1 {
  background-color: #6A1B9A;
  color: white;
  flex-direction: column;
}

.section-2 {
  background: yellow url(https://images.unsplash.com/photo-1592989478913-6fd5b9ed8770?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=400&fit=max&ixid=eyJhcHBfaWQiOjE0NTg5fQ) center center no-repeat;
  background-position: fixed;
  background-size: cover;
}

.section-3 {
  background: yellow url(https://images.unsplash.com/photo-1591942241243-7cd5619f2b95?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=400&fit=max&ixid=eyJhcHBfaWQiOjE0NTg5fQ) center center no-repeat;
  background-position: fixed;
  background-size: cover;
}

.section-4 {
  background: yellow url(https://images.unsplash.com/photo-1592334319415-574f0d16bc6d?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=400&fit=max&ixid=eyJhcHBfaWQiOjE0NTg5fQ) center center no-repeat;
  background-position: fixed;
  background-size: cover;
}

.curtain {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0,0,0,0.8);
}

.page-title {
  font-size: 200%;
  font-weight: 700;
  text-align: center;
}

@media(min-width: 800px) {
  .page-title {
    font-size: 300%;
  }
}

.arrow {
  fill: white;
  width: 50px;
}

.text {
  background: rgba(245, 245,66,0.7);
  padding: 1rem;
  border-radius: 10px;
  line-height: 1.5;
  box-shadow: 2px 2px 2px 2px #000000;
}

.text::first-letter {
  font-weight: bold;
  margin: 0;
  margin-right: 0.8rem;
  margin-top: -18px;
  padding: 0;
  float: left;
  font-size: 5rem;
  font-family: 'Tangerine', cursive;
  font-weight: 700;
  text-shadow: 1px 2px 1px #333333;
}
              
            
!

JS

              
                // register ScrollTrigger only once
gsap.registerPlugin(ScrollTrigger)

// set some properties before the animation starts
gsap.set('.text', {autoAlpha: 0, scale: 0, y: 200})

// arrow animation
gsap.to('.arrow', {
  y: -5,
  repeat: -1,
  yoyo: true,
  ease: 'linear'
})

// select the elements to animate 
// on scroll
const panels = document.querySelectorAll('.curtain')
const text = document.querySelectorAll('.text')

// attach the animation to each 
// selected panel
panels.forEach((panel) => {
  gsap.to(panel, {
    scrollTrigger: {
      trigger: panel,
      start: 'top center',
      toggleActions: 'play reverse restart reverse'
    },
    bottom: '100%',
    duration: 1,
    ease: 'linear'
  })
})

// attach the animation to the text 
text.forEach((verse) => {
  gsap.to(verse, {
    autoAlpha: 1,
    scale: 1,
    y: 0,
    duration: 1.5,
    delay: 0.5,
    ease: 'circ.inOut',
    scrollTrigger: verse
  })
})


              
            
!
999px

Console