<button>Test 1</button>

<button>Test 2</button>

<button>Test 3</button>


<p>Based on GeekLaunch channel video: https://www.youtube.com/watch?v=QI2rDHQM5Pc</p>
body{
  background-color: #efefef;
}

button{
  font-family: 'Roboto';
  font-size: 24px;
  padding: 1em 2em;
  margin: 2px;
  border: 0;
  outline: 0;
  color: white;
  background-color: #2196f3;
  text-transform: uppercase;
  border-radius: 0.15em;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.3 );
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

button .ripple{
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.7);
  position: absolute;
  transform: scale(0);
  animation: ripple 0.6s linear;
}

@keyframes ripple{
  to{
    transform: scale(2.5);
    opacity: 0;
  }
}
var buttons = document.getElementsByTagName('button');

Array.prototype.forEach.call(buttons, function(b){
  b.addEventListener('click', createRipple);
})

function createRipple(e)
{
  if(this.getElementsByClassName('ripple').length > 0)
    {
      this.removeChild(this.childNodes[1]);
    }
  
  var circle = document.createElement('div');
  this.appendChild(circle);
  
  var d = Math.max(this.clientWidth, this.clientHeight);
  circle.style.width = circle.style.height = d + 'px';
  
  circle.style.left = e.clientX - this.offsetLeft - d / 2 + 'px';
  circle.style.top = e.clientY - this.offsetTop - d / 2 + 'px';
  
  circle.classList.add('ripple');
}

External CSS

  1. https://fonts.googleapis.com/css?family=Roboto:300,400,700

External JavaScript

This Pen doesn't use any external JavaScript resources.