cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

            
              <div class="flick"></div>
Should flick 1 to 2

<div class="flick flick-end"></div>
Flick w/ step-end

<div class="flick flick-start"></div>
Flick w/ step-start

<div class="easy-as"></div>
1-2-3

<div class="easy-as easy-working"></div>
1-2-3 with the "fourth frame"

<div class="easy-as easy-borked"></div>
1-2-3 with the "fourth frame" showing and the "first frame" missing.

<div class="flick flick-working"></div>
Now we get some flicking action.
            
          
!
            
              body { padding: 1em; }

div {
  margin: 1em 0 .5em;
  width: 50px; height: 50px;
}

@keyframes countdown {  
  0% { background-position: 0 0; } 
  100% {background-position: 0 100%; } 
}

/* You think the following would flick between 1 and 2 forever, right? Steps() is supposed to split the output into an equal number of segments and jump between them, right?  */
.flick {
  animation: countdown 1s steps(2) infinite;
  background: url(http://stash.rachelnabors.com/img/codepen/1-2.png) 0 0 no-repeat;
}

/* That's weird. It's only going halfway between 1 and 2. Hmmm... 

Let's try experimenting with those "start" and "end" properties. Those worked great for me before! (See also https://codepen.io/CrowChick/pen/bpAJH) */

.flick-end {
  animation: countdown 1s steps(1, end) infinite;
}

.flick-start {
  animation: countdown 1s steps(1, start) infinite;
}

/* Those look like they just skip us to the first or the last frame, though... Why is that?

According to: http://www.css3files.com/animation/ 
"Step(X, start/end) in turn enables to define how many steps are shown between each keyframe, where X stands for the steps and start/end defines if the first or the last keyframe should be omitted (defaults to end if omitted)."

Wait... WHICH KEYFRAME SHOULD BE OMITTED? DEFAULTS TO "END?" Oh. My. God. CSS3 steps() animations EAT THEIR OWN KEYFRAMES.

Let's calm down and try a longer animation and see if we can at least get this thing moving again. */
.easy-as {
  animation: countdown 1s steps(2, end) infinite;
  background: url(http://stash.rachelnabors.com/img/codepen/1-2-3.png) 0 0 no-repeat;
}

/* What's happening here is that it's splitting the 1-2-3 image into three equal parts and then ignoring the last one, the "end." I have no idea why this is the case. But watch what happens when we add change the animation to have an extra "blank frame" at the end--remember that the 1-2-3 image is 150px high. By using background-position: 0 -150px, you'd think the last frame would be missing, as the image would be "off screen" at 100% */

@keyframes countdownTo3 {  
  0% { background-position: 0 0; } 
  100% {background-position: 0 -150px; } 
}

.easy-working {
  animation: countdownTo3 1s steps(3) infinite;
}

/* It works perfectly, though, as the last "blank frame" at 100% is consumer by steps(3, end)--remember "end" is the default value, so no need to specify that value unless using start. Speaking of which, here's what happens when you use that...*/

.easy-borked {
  animation: countdownTo3 1s steps(3, start) infinite;
}

/* Now that we know all this, let's revisit flick above. */

@keyframes countdownTo2 {  
  0% { background-position: 0 0; } 
  100% {background-position: 0 -100px; } 
}

.flick-working {
  animation: countdownTo2 1s steps(2) infinite;
}

/* The only other write up I could find was at Mozilla.org and shamefully missing its images: https://developer.mozilla.org/en-US/docs/CSS/timing-function#The_steps()_class_of_timing-functions

Seriously not much is written about these.

I'm off to update all my walkcycle animations because they are missing a frame. Ta! */
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console