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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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 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)

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.


Loading ..................