css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <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="http://www.javascriptkit.com/javatutors/css-transition-functions.shtml" 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 (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)
🕑 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 ..................