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="bucket">
<div id="water"></div>
<div id="bucketcount">0</div>

<button onClick="document.getElementById('bucket').classList.add('fillit')">Fill With Water</button>

<br />
<p>The following demo uses CSS3 keyframe animatiion to create a simple bucket fill animation. After each iteration of the animation, we count the number of times the bucket has been filled by keeping track of the number of times <code>animationiteration</code> has been fired.</p>

<p style="position:absolute;bottom:10px">From tutorial <a href="" target+"_new">Four Essential JavaScript functions to tame CSS3 Transitions and Animations</a></p>


  width: 250px;
  height: 120px;
  background: white;
  border: 10px solid black;
  border-top-width: 0;
  position: relative;
  overflow: hidden;

#bucket #water{
  content: '';
  position: absolute;
  background: lightblue;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  -webkit-transform: translate3d(0,100%,0);
  transform: translate3d(0,100%,0);

#bucket.fillit #water{
  -webkit-animation: fillwater 3s ease-in-out forwards infinite;
  animation: fillwater 3s ease-in-out forwards infinite;

@-webkit-keyframes fillwater{
    100%{-webkit-transform: translate3d(0,0,0)}
@keyframes fillwater{
    100%{transform: translate3d(0,0,0)}

  font: bold 80px Arial;
  text-align: center;
    position: relative;
    z-index: 2;


                function getanimationevent(suffix){ // enter "start", "iteration", or "end"
    var root = document.documentElement
    var suffix = suffix.toLowerCase()
    var animations = {
        'animation': 'animation' + suffix,
        'OAnimation': 'oAnimation' + suffix.charAt(0).toUpperCase() + suffix.slice(1), // capitalize first letter of suffix
        'MozAnimation': 'animation' + suffix,
        'WebkitAnimation': 'webkitAnimation' + suffix.charAt(0).toUpperCase() + suffix.slice(1)
    for (var a in animations){
        if ([a] !== undefined ){
            return animations[a]
    return undefined
// getanimationevent('start') // returns supported version of "animationstart" event as a string
// getanimationevent('iteration') // returns supported version of "animationiteration" event as a string
// getanimationevent('end') // returns supported version of "animationend" event as a string
//Example usage:
var water = document.getElementById('water')
var bucketcount = document.getElementById('bucketcount')
var curcount = 0
var animationiteration = getanimationevent('iteration')
if (animationiteration){
    water.addEventListener(animationiteration , function(e){
        bucketcount.innerText = ++curcount
    }, false)