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

              
                <!-- 
This is a simple clap animation done using HTML, CSS and JS. Click on it to start the animation. 

The animation only happens on the first click.
A user can only clap once so as to avoid duplicate claps.
-->

<div class="clapsdiv">
  <div class="clapforpost">
    <div id="postclapped">
      <p>+1</p>
    </div>
    <div id="tophand" onclick="clapforme(this)">
      <svg class="clappinghands topclap" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60.75 42.39">
        <path class="cls-top-1" d="M44.48,23.48A1.89,1.89,0,0,0,42,23.6c-2.57,2.63-5.2,5.22-7.8,7.82-.23.23-.47.4-.75.13s-.1-.52.13-.75c2.5-2.49,5-5,7.49-7.48a2.2,2.2,0,0,0,.83-2.07,1.77,1.77,0,0,0-1.23-1.4,1.89,1.89,0,0,0-2,.43c-1,1-2,2-2.95,2.94l-4.82,4.85-.09.08c-.22.23-.47.29-.69.05s-.14-.47.08-.69c1.35-1.34,2.69-2.69,4-4,.77-.78,1.55-1.55,2.31-2.35a1.73,1.73,0,0,0-.05-2.5,1.8,1.8,0,0,0-2.52.07c-1.54,1.52-3.07,3.06-4.6,4.59s-3.21,3.21-4.81,4.81l-.34.37c1,1,2,2,3,3a5.74,5.74,0,0,1,0,7.92.88.88,0,0,1-.54.2c-.09,0-.27-.21-.27-.32a.87.87,0,0,1,.22-.5,4.93,4.93,0,0,0,1.25-2.63,4.69,4.69,0,0,0-1.26-4.06c-1-1.08-2.11-2.1-3.14-3.17a1,1,0,0,1-.28-.64c-.08-1-.05-2.07-.17-3.08a3.47,3.47,0,0,0-3.35-3c-.43,0-.64.19-.66.66,0,.82-.05,1.64-.08,2.46-.08,2.8-.18,5.59-.25,8.38a12.35,12.35,0,0,0,3.39,9,7.93,7.93,0,0,0,11.45,0c3.62-3.68,7.26-7.33,10.89-11a1.62,1.62,0,0,0,.43-2.07,1.42,1.42,0,0,0-2.23-.29c-1.75,1.77-3.52,3.53-5.28,5.29-.22.21-.46.35-.71.08s-.12-.51.1-.73c1.55-1.54,3.1-3.07,4.64-4.62Q42.95,27.7,44.55,26A1.79,1.79,0,0,0,44.48,23.48Z" transform="translate(-1.53 -8.55)" />
        <path class="cls-top-2" d="M42.8,22.16a2.77,2.77,0,0,0-1.47-3,2.91,2.91,0,0,0-3.41.52,2.66,2.66,0,0,0-1.21-2,2.71,2.71,0,0,0-3.34.36c-1.7,1.68-3.38,3.38-5.07,5.07l-3.95,3.95a.86.86,0,0,1-.4.23V25.92a4.46,4.46,0,0,0-1.63-3.6,4.09,4.09,0,0,0-2.92-1,1.33,1.33,0,0,0-1.26,1.26c-.06,1.68-.11,3.36-.16,5-.07,2-.14,4-.19,6A12.87,12.87,0,0,0,22.24,44,8.13,8.13,0,0,0,27,46a8.43,8.43,0,0,0,6.25-1.88,36.06,36.06,0,0,0,2.67-2.58c1.62-1.62,3.22-3.25,4.84-4.88s3-3,4.51-4.56a2.39,2.39,0,0,0-1-3.92L43.74,28c.52-.49,1-.89,1.42-1.34a2.52,2.52,0,0,0,.72-2.33,2.6,2.6,0,0,0-2.75-2.16ZM42,23.6a1.89,1.89,0,0,1,2.48-.12A1.79,1.79,0,0,1,44.55,26q-1.61,1.66-3.22,3.32c-1.54,1.55-3.09,3.08-4.64,4.62-.22.22-.35.46-.1.73s.49.13.71-.08c1.76-1.76,3.53-3.52,5.28-5.29a1.42,1.42,0,0,1,2.23.29,1.62,1.62,0,0,1-.43,2.07c-3.63,3.66-7.27,7.31-10.89,11a7.93,7.93,0,0,1-11.45,0,12.35,12.35,0,0,1-3.39-9c.07-2.79.17-5.58.25-8.38,0-.82.05-1.64.08-2.46,0-.47.23-.68.66-.66a3.47,3.47,0,0,1,3.35,3c.12,1,.09,2.05.17,3.08a1,1,0,0,0,.28.64c1,1.07,2.12,2.09,3.14,3.17a4.69,4.69,0,0,1,1.26,4.06,4.93,4.93,0,0,1-1.25,2.63.87.87,0,0,0-.22.5c0,.11.18.32.27.32a.88.88,0,0,0,.54-.2,5.74,5.74,0,0,0,0-7.92c-1-1-2-2-3-3l.34-.37c1.6-1.6,3.21-3.2,4.81-4.81s3.06-3.07,4.6-4.59a1.8,1.8,0,0,1,2.52-.07,1.73,1.73,0,0,1,.05,2.5c-.76.8-1.54,1.57-2.31,2.35-1.35,1.35-2.69,2.7-4,4-.22.22-.31.46-.08.69s.47.18.69-.05l.09-.08,4.82-4.85c1-1,1.95-2,2.95-2.94a1.89,1.89,0,0,1,2-.43,1.77,1.77,0,0,1,1.23,1.4,2.2,2.2,0,0,1-.83,2.07c-2.5,2.48-5,5-7.49,7.48-.23.23-.41.47-.13.75s.52.1.75-.13C36.8,28.82,39.43,26.23,42,23.6Z" transform="translate(-1.53 -8.55)" />
      </svg>
    </div>
    <div id="bottomhand">
      <svg class="clappinghands" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60.75 42.39">
        <path class="cls-vibration1" d="M23.47,20.74c.35.13.5-.11.6-.4a10,10,0,0,1,2.59-3.87A9.34,9.34,0,0,1,31,14.31l.37-.08c.28,0,.46-.22.38-.48s-.27-.3-.37-.4a10.76,10.76,0,0,0-3.67,1.31A10.26,10.26,0,0,0,23.26,20C23.14,20.32,23.1,20.61,23.47,20.74Z" transform="translate(-4.53 -11.55)" />
        <path class="cls-vibration2" d="M31.86,16.61c.25-.08.44-.23.37-.51a.43.43,0,0,0-.57-.34,8.33,8.33,0,0,0-6.1,4.7c-.17.33-.3.68-.49,1.11.14.13.28.34.42.35a.64.64,0,0,0,.48-.27c.26-.46.43-1,.7-1.42a7.36,7.36,0,0,1,5.07-3.59Z" transform="translate(-4.53 -11.55)" />
        <path class="cls-bottom-1" d="M44.48,23.48A1.89,1.89,0,0,0,42,23.6c-2.57,2.63-5.2,5.22-7.8,7.82-.23.23-.47.4-.75.13s-.1-.52.13-.75c2.5-2.49,5-5,7.49-7.48a2.2,2.2,0,0,0,.83-2.07,1.77,1.77,0,0,0-1.23-1.4,1.89,1.89,0,0,0-2,.43c-1,1-2,2-2.95,2.94l-4.82,4.85-.09.08c-.22.23-.47.29-.69.05s-.14-.47.08-.69c1.35-1.34,2.69-2.69,4-4,.77-.78,1.55-1.55,2.31-2.35a1.73,1.73,0,0,0-.05-2.5,1.8,1.8,0,0,0-2.52.07c-1.54,1.52-3.07,3.06-4.6,4.59s-3.21,3.21-4.81,4.81l-.34.37c1,1,2,2,3,3a5.74,5.74,0,0,1,0,7.92.88.88,0,0,1-.54.2c-.09,0-.27-.21-.27-.32a.87.87,0,0,1,.22-.5,4.93,4.93,0,0,0,1.25-2.63,4.69,4.69,0,0,0-1.26-4.06c-1-1.08-2.11-2.1-3.14-3.17a1,1,0,0,1-.28-.64c-.08-1-.05-2.07-.17-3.08a3.47,3.47,0,0,0-3.35-3c-.43,0-.64.19-.66.66,0,.82-.05,1.64-.08,2.46-.08,2.8-.18,5.59-.25,8.38a12.35,12.35,0,0,0,3.39,9,7.93,7.93,0,0,0,11.45,0c3.62-3.68,7.26-7.33,10.89-11a1.62,1.62,0,0,0,.43-2.07,1.42,1.42,0,0,0-2.23-.29c-1.75,1.77-3.52,3.53-5.28,5.29-.22.21-.46.35-.71.08s-.12-.51.1-.73c1.55-1.54,3.1-3.07,4.64-4.62Q42.95,27.7,44.55,26A1.79,1.79,0,0,0,44.48,23.48Z" transform="translate(-1.53 -8.55)" />
        <path class="cls-bottom-2" d="M42.8,22.16a2.77,2.77,0,0,0-1.47-3,2.91,2.91,0,0,0-3.41.52,2.66,2.66,0,0,0-1.21-2,2.71,2.71,0,0,0-3.34.36c-1.7,1.68-3.38,3.38-5.07,5.07l-3.95,3.95a.86.86,0,0,1-.4.23V25.92a4.46,4.46,0,0,0-1.63-3.6,4.09,4.09,0,0,0-2.92-1,1.33,1.33,0,0,0-1.26,1.26c-.06,1.68-.11,3.36-.16,5-.07,2-.14,4-.19,6A12.87,12.87,0,0,0,22.24,44,8.13,8.13,0,0,0,27,46a8.43,8.43,0,0,0,6.25-1.88,36.06,36.06,0,0,0,2.67-2.58c1.62-1.62,3.22-3.25,4.84-4.88s3-3,4.51-4.56a2.39,2.39,0,0,0-1-3.92L43.74,28c.52-.49,1-.89,1.42-1.34a2.52,2.52,0,0,0,.72-2.33,2.6,2.6,0,0,0-2.75-2.16ZM42,23.6a1.89,1.89,0,0,1,2.48-.12A1.79,1.79,0,0,1,44.55,26q-1.61,1.66-3.22,3.32c-1.54,1.55-3.09,3.08-4.64,4.62-.22.22-.35.46-.1.73s.49.13.71-.08c1.76-1.76,3.53-3.52,5.28-5.29a1.42,1.42,0,0,1,2.23.29,1.62,1.62,0,0,1-.43,2.07c-3.63,3.66-7.27,7.31-10.89,11a7.93,7.93,0,0,1-11.45,0,12.35,12.35,0,0,1-3.39-9c.07-2.79.17-5.58.25-8.38,0-.82.05-1.64.08-2.46,0-.47.23-.68.66-.66a3.47,3.47,0,0,1,3.35,3c.12,1,.09,2.05.17,3.08a1,1,0,0,0,.28.64c1,1.07,2.12,2.09,3.14,3.17a4.69,4.69,0,0,1,1.26,4.06,4.93,4.93,0,0,1-1.25,2.63.87.87,0,0,0-.22.5c0,.11.18.32.27.32a.88.88,0,0,0,.54-.2,5.74,5.74,0,0,0,0-7.92c-1-1-2-2-3-3l.34-.37c1.6-1.6,3.21-3.2,4.81-4.81s3.06-3.07,4.6-4.59a1.8,1.8,0,0,1,2.52-.07,1.73,1.73,0,0,1,.05,2.5c-.76.8-1.54,1.57-2.31,2.35-1.35,1.35-2.69,2.7-4,4-.22.22-.31.46-.08.69s.47.18.69-.05l.09-.08,4.82-4.85c1-1,1.95-2,2.95-2.94a1.89,1.89,0,0,1,2-.43,1.77,1.77,0,0,1,1.23,1.4,2.2,2.2,0,0,1-.83,2.07c-2.5,2.48-5,5-7.49,7.48-.23.23-.41.47-.13.75s.52.1.75-.13C36.8,28.82,39.43,26.23,42,23.6Z" transform="translate(-1.53 -8.55)" />
        <path class="cls-vibration2" d="M45.62,36.79c-.26.2-.61.37-.37.79s.46.25.9-.09a8.22,8.22,0,0,0,3.44-6.74v-.62c0-.33-.12-.61-.5-.58s-.43.29-.4.6a7,7,0,0,1-.37,3.08A7.56,7.56,0,0,1,45.62,36.79Z" transform="translate(1.53 -6.55)" />
        <path class="cls-vibration1" d="M52,30.79c0-.23,0-.47,0-.7,0-.48-.18-.71-.49-.67s-.43.38-.39.7a8.25,8.25,0,0,1-.27,3.05,9.4,9.4,0,0,1-3.57,5.18c-.11.09-.23.17-.33.26a.39.39,0,0,0-.1.61.41.41,0,0,0,.62.08A11.2,11.2,0,0,0,49.94,37,9.76,9.76,0,0,0,52,30.79Z" transform="translate(1.53 -6.55)" />
      </svg>
    </div>
  </div>
  <div class="showclaps">
    <p id="clapscounter"> 0
    </p>
  </div>
</div>
              
            
!

CSS

              
                .clapsdiv {
  position: fixed;
  top: 35%;
  left: 45%;
  text-align: center;
}
.clapforpost {
  position: relative;
  height: 120px;
  width: 120px;
}
.showclaps {
  position: relative;
  font-weight: bold;
  text-align: center;
}
.clappinghands {
  height: 120px;
  width: 120px;
}
.clapforpost div {
  position: absolute;
  left: 0;
  right: 0;
  margin: auto;
}
#tophand {
  cursor: pointer;
  z-index: 10;
}
.topclap {
  margin-top: 2px;
  margin-left: -8px;
}
#bottomhand {
  background: #27ae60;
  border-radius: 50%;
}
.applauseanimation {
  animation: clapping 0.2s 7;
}
.reverseclapping {
  animation: reverseclapping 0.2s 7;
}
.vibration-bottom {
  animation: vibration-1-bottom 0.2s 7;
}
.clapscounter {
  animation: clapscounter 0.2s 1 ease-in-out;
}
.disableclaps {
  cursor: default;
  pointer-events: none;
}
.vibration-top {
  animation: vibration-1-top 0.2s 7;
}
.cls-top-1,
.cls-bottom-1,
.cls-vibration1,
.cls-vibration2 {
  fill: white;
}

.cls-top-2,
.cls-bottom-2 {
  fill: black;
}
#postclapped {
  width: 40px;
  height: 40px;
  border: 1px solid #27ae60;
  padding: 1px;
  color: white;
  background:#27ae60;
  border-radius: 50%;
}
#postclapped p {
  line-height: 5px;
  text-align: center;
}
.addclaps {
  animation: addclaps 0.5s 1;
}
@keyframes vibration-1-bottom {
  0% {
    opacity: 0;
  }
  25% {
    opacity: 0.25;
  }
  50% {
    opacity: 0.5;
  }
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes vibration-1-top {
  0% {
    opacity: 0;
  }
  25% {
    opacity: 0.25;
  }
  50% {
    opacity: 0.5;
  }
  75% {
    opacity: 0.75;
  }
  100% {
    opacity: 1;
  }
}

@keyframes clapping {
  0% {
    transform: scale(1);
  }
  100% {
    transform: scale(0.7);
  }
}
@keyframes clapscounter {
  0% {
    margin-top: -20px;
    opacity: 0;
  }
  50% {
    opacity: 0.5;
  }
  100% {
    margin-top: 0;
    opacity: 1;
  }
}
@keyframes addclaps {
  0% {
    margin-top: 40px;
    opacity: 0;
  }
  50% {
    opacity: 0.5;
  }
  75% {
    margin-top: -60px;
    opacity: 1;
  }
  90% {
    opacity: 0.5;
  }
  100% {
    opacity: 0;
  }
}
              
            
!

JS

              
                function clapforme(element) {
    var bottomhand = document.getElementById("bottomhand");
    var vibrations1 = document.getElementsByClassName("cls-vibration1");
    var vibrations2 = document.getElementsByClassName("cls-vibration2");
  var claps = document.getElementById("postclapped");
  var clapscounter = document.getElementById("clapscounter");
    for (let i = 0; i < vibrations1.length; i++) {
        vibrations1[i].classList.add("vibration-top");
        vibrations2[i].classList.add("vibration-bottom");
    }
  element.classList.add("applauseanimation", "disableclaps");
    bottomhand.style.backgroundColor = "grey";
  clapscounter.innerHTML = 1;
  clapscounter.classList.add("clapscounter");
  claps.classList.add("addclaps");
}
              
            
!
999px

Console