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="bird"></div>
<div class="pirate"></div>

<!--

Read the full article here:
https://sid.studio/post/css-animation

-->
              
            
!

CSS

              
                /* the skies are blue */
body { 
  background: #9ae2ff;
  overflow: hidden;
}
 
/* set up the graphics: */

.bird {
  background-image: url("https://react.games/bird.png");
  transform: rotate(-9deg);
}
.pirate {
  top: 27px;
  margin-left: 49px;
  background-image: url("https://react.games/pirate-hanging.png");
}

/* common styles for pirate and bird */
.pirate,
.bird {
  position: absolute;
  width: 75px;
  height: 125px;
  background-repeat: no-repeat;
  background-size: contain;
}

/* choreography 

0     1     2     3     4     5         6     7     8     9s
←---------  enter  --------⇥ ← pause ⇥ ←----- exit ---⇥

0 - 5s : enter animation
5 - 6s : pause
6 - 9s : exit animation

*/

.bird {
  /*         ↓ enter animation       ↓ exit animation   */
  animation: bird-enter 5s ease-out, bird-exit 3s ease-in;
  /* 0s delay for the entry animation, 6s for the exit  */
  animation-delay: 0s, 6s;
}
.pirate {
    animation: bird-enter 5s ease-out, fall 3s ease-in;
    animation-delay: 0s, 6s;
}
 
.bird,
.pirate {
  animation-fill-mode: forwards;
  /*
    with fill-mode: forwards, the
    charachters retain their position
    after the animation is finished.
  */
}

/* keyframe animations */

@keyframes bird-enter {
  from {
    transform: translateX(100vw);
  }
  to {
    transform: translateX(50vw); /* half way */
  }
}

@keyframes bird-exit {
  from {
    transform: translateX(50vw);
  }
  to {
    transform: translateX(-10vw); /* exit outside the frame */
  }
}
 
@keyframes fall {
  from {
    transform: translateX(50vw) rotate(0deg);
    background-image: url("https://react.games/pirate-falling.png");
  }
  to {
    transform: translateX(50vw) translateY(100vw) rotate(90deg);
    background-image: url("https://react.games/pirate-falling.png");
  }
}

/*

Read the full article here:
https://sid.studio/post/css-animation

*/

              
            
!

JS

              
                
              
            
!
999px

Console