Pen Settings



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


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


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.


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.


                <div id='barn'>🏡</div>
<div id='farmyard'>
  <div id='goat' class='animal'>🐐</div>
  <div id='rooster' class='animal'>🐓</div>
  <div id='pig' class='animal'>🐖</div>


                #farmyard {
  position: relative;

.animal {
  position: absolute;
   * before the animation, --animation is 0. After, it's 1.
   *   calc(x - (y * var(--animation)))
   * can be read as "animate from x to (y-x)"
  /* animate from `left: 50%` to `left: 0`" */
  left: calc(50% - (50% * var(--animation)));
  transform: translateX(-50%);
  /* animate from `font-size: 6em` to `font-size: 1em` */
  font-size: calc(6em - (5em * var(--animation)));
  /* animate from `rotate(0)` to `rotate(-15deg)` */
  transform: rotate(calc(-15deg * var(--animation)));

#goat {
  --animation: var(--first-animation);
  bottom: -300px;

#rooster {
  bottom: -600px;
  /* Ease in exponential. You could also do this calculation
   * in JavaScript and set another custom property, so this
   * would become:
   *   --animation: var(--second-animation-exponential)
  --animation: var(--second-animation) * var(--second-animation) *

#pig {
  bottom: -900px;
  --animation: var(--third-animation);

body {
  height: 1600px;

#barn {
  position: fixed;
  left: 0;
  top: 0;
  font-size: 8em;
  z-index: 1;
  background: white;



                const triggers = [
  { name: "first", from: 0, to: 275 },
  { name: "second", from: 300, to: 525 },
  { name: "third", from: 600, to: 850 }

function animationPercentage(trigger, scrollY) {
  if (scrollY < trigger.from) return 0;
  if (scrollY > return 1;
  return (scrollY - trigger.from) / ( - trigger.from);

function updateTriggers(e) {
  triggers.forEach(trigger => {
    /* To support more complex easing, you could set multiple properties,
     * each one corresponding to a different timing function.
     * E.g. --${}-animation-ease-in-out
     * and you would compute the percentage based on the linear animation percentage used here
    const property = `--${}-animation`;
      animationPercentage(trigger, window.scrollY)

window.addEventListener("scroll", updateTriggers);