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

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

<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="http://www.javascriptkit.com/javatutors/css-transition-functions.shtml" target+"_new">Four Essential JavaScript functions to tame CSS3 Transitions and Animations</a></p>
              
            
!

CSS

              
                #bucket{
  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)}
}

#bucketcount{
  font: bold 80px Arial;
  text-align: center;
    position: relative;
    z-index: 2;
}
              
            
!

JS

              
                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 (root.style[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)
}
              
            
!
999px

Console