Pen Settings

HTML

CSS

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

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

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.

HTML

              
                <div class="toaster frame f1"></div>
<div class="toaster frame f2"></div>
<div class="toaster frame f3"></div>
<div class="toaster frame f4"></div>

<!-- The resulting animated sprite -->
<div class="toaster animated"></div>
              
            
!

CSS

              
                /**
 * Define your sprite as the background
 * image of a block element, like a div.
 * 
 * Make sure to constrain the width and
 * height to the size of one sprite frame. 
 */
.toaster {
  background: url(http://bryanbraun.com/assets/images/toaster-sprite.gif) no-repeat;
  width: 64px;
  height: 64px;
}

/**
 * The animation property (and its values):
 * 
 *  "flap"
 *     The name of the keyframe in use.
 *
 *  "0.4s" 
 *     The duration of the animation from
 *     beginning to end. 
 *
 *  "steps(4)"
 *     Important! Break our keyframe motion
 *     into 4 equals steps, one for each
 *     sprite position. 
 *
 *  "infinite"
 *     Repeat the animation infinitely.
 * 
 *  "alternate"
 *     With each loop of the animation,
 *     reverse the direction.
 */
.animated {
  -webkit-animation: flap .4s steps(4) infinite alternate;
  -moz-animation: flap .4s steps(4) infinite alternate;
  -ms-animation: flap .4s steps(4) infinite alternate;
  -o-animation: flap .4s steps(4) infinite alternate;
  animation: flap .4s steps(4) infinite alternate;
}

/**
 * Keyframes for the animation.
 *
 * We define the beginning and ending
 * background position for our image
 * sprite. This is divided into
 * equal steps by the animation
 * property above.
 */
@-webkit-keyframes flap {
  from { background-position:  0%; }
  to { background-position: -256px; }
}
@-moz-keyframes flap {
  from { background-position:  0px; }
  to { background-position: -256px; }
}
@-ms-keyframes flap {
  from { background-position:  0px; }
  to { background-position: -256px; }
}
@-o-keyframes flap {
  from { background-position:  0px; }
  to { background-position: -256px; }
}
@keyframes flap {
  from { background-position:  0px; }
  to { background-position: -256px; }
}





/**
 * -- unimportant --
 *
 * (layout & styling for demonstration)
 */
.frame {
  width: 256px;
  padding-left: 194px;
  position: relative;
}
.frame:before {
  position: absolute;
  margin: -2px 0 0 -2px;
  width: 256px;
  height: 64px;
  border: 2px solid white;
  content: "";
}
.frame.f2:before {
  left: 128px;
}
.frame.f3:before {
  left: 64px; 
}
.frame.f4:before {
  left: 3px;
}
.frame:after {
  position: relative;
  display: block;
  margin: -5px 0 0 -5px;
  width: 64px;
  height: 64px;
  border: 5px solid red;
  content: "";
  float: left;
}
.f1 { background-position: 194px; }
.f2 { background-position: 128px; }
.f3 { background-position: 64px; }
.f4 { background-position: 0px; }

body {
  background-color: #111;
}
body > div {
  margin: 1em auto;
}
              
            
!

JS

              
                /**
 * CSS Spriting Demo 
 * 
 * See the full set of animated screensavers at
 * https://bryanbraun.github.io/after-dark-css/
 *
 * by Bryan Braun
 * http://bryanbraun.com
 */
              
            
!
999px

Console