# 鼠标点击水波效果

# 动画效果

# 代码实现

# css

.wave {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: #91e6f1;
  position: absolute;
  animation: wave 0.32s ease;
  -webkit-animation:wave 0.32s ease;
  -moz-animation:wave 0.32s ease;
  -o-animation:wave 0.32s ease;
  opacity: 1;
}

@keyframes wave {
  0% {
    transform: scale(0.1);
    opacity: 0.0;
  }
  25% {
    transform: scale(0.3);
    opacity: 0.3;
  }
  50% {
    transform: scale(0.7);
    opacity: 0.8;
  }
  75% {
    transform: scale(0.8);
    opacity: 0.4;
  }
  100% {
    transform: scale(1);
    opacity: 0.2;
  }
}

# javascript

document.onclick = function(e) {
  e = e || window.event
  let [x,y] = [e.pageX, e.pageY]
  let ele = document.createElement('div')
  ele.classList.add('wave')
  ele.style.left = x - 25 + 'px'
  ele.style.top = y - 25 + 'px'
  document.body.appendChild(ele)
  setTimeout(() => {
    ele.parentNode.removeChild(ele)
  }, 300)
}