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 class="box purple a">a</div>
<div class="box green b">b</div>
<!-- <div class="box ghost">c</div> -->
<!-- <div class="box orange c">c</div> -->



<div class="line"></div>
              
            
!

CSS

              
                /* this demo has external styles added in the settings */
/* https://codepen.io/GreenSock/pen/xxmzBrw?editors=1100 */

.box.active {
  outline: 5px dashed var(--color-surface-white);
}


body {
  background-color: var(--color-just-black);
  background-image:
    linear-gradient(rgba(255,255,255,.07) 2px, transparent 2px),
    linear-gradient(90deg, rgba(255,255,255,.07) 2px, transparent 2px),
    linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px);
  background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
  background-position: -2px -2px, -2px -2px, -1px -1px, -1px -1px;
}

.box {
  width: 100px;
  height: 100px;
  position: absolute;
  left: 100px;
  z-index: 100;
}

.a {
  top: 200px;
}

.b {
  top: 800px;
}

.c {
  top: 1000px;
}

.ghost {
  top: 1000px;
  background-color: #444;
}

.line {
  width: 2px;
  height: 3000px;
  position: absolute;
  left: 600px;
  top: 0px;
/*   visibility: hidden; */
  background-color: #777;
}

              
            
!

JS

              
                // For more information, see greensock.com/docs/v3/Plugins/ScrollTrigger
gsap.registerPlugin(ScrollTrigger);

// You can use a ScrollTrigger in a tween or timeline
let tl = gsap.timeline({
  scrollTrigger: {
    trigger: ".b",
    start: "top bottom",
    end: "bottom top",
    scrub: true,
    markers: true,
    id: "scrub"
  } 
})
tl.to(".b", {
  duration: 1,
  x: 400,
  rotation: 360,
})
.to(".b", {
  duration: 2,
  scale: 2
});


// // Or you can attach a tween or timeline to a ScrollTrigger later
// const anim = gsap.to(".c", {
//   x: 400,
//   rotation: 360,
//   duration: 3
// });

// ScrollTrigger.create({
//   trigger: ".c",
//   animation: anim,
//   // Uncomment these to see how they affect the ScrollTrigger
//   // markers: true,
//   start: "top center",
//   end: "top 100px",
//   toggleClass: "active",
//   // pin: true,
//   // scrub: 1,
//   // onUpdate: self => {
//   //   console.log("progress:", self.progress.toFixed(3), "direction:", self.direction, "velocity", self.getVelocity());
//   // }
// });



// 💚 This just adds the GSAP link to this pen, don't copy this bit
import { GSAPInfoBar } from "https://codepen.io/GreenSock/pen/vYqpyLg.js"
new GSAPInfoBar({ link: "https://gsap.com/docs/v3/Plugins/ScrollTrigger/"});
// 💚 Happy tweening!
              
            
!
999px

Console