<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css">

<div class="container">
  <div class="card">
    <div class="card__body">
      <div class="item">
        <div class="item--bg"></div>
        <i class="fas fa-heart"></i>
      </div>
      Click bellow
    </div>
    <button onclick="change()">Click me</button>
  </div>
</div>
@import url('https://fonts.googleapis.com/css2?family=Montserrat&display=swap');

* {
  margin: 0px;
  padding: 0px;
  box-sizing: border-box;
}

body {
  background-color: #fff3e5;
}

.container {
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  background-color: #ffffff;
  box-shadow: 4px 5px 15px 0px rgb(241,230,219);
  border-radius: 20px;
  padding: 0px 15px 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.card__body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 50px 50px 20px;
  font-family: 'Montserrat', sans-serif;
  font-size: 15px;
  font-weight: bold;
  color: #292d30;
  position: relative;
}

.item {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(321deg, rgba(252,91,91,1) 0%, rgba(252,159,160,1) 100%);
  box-shadow: 4px 5px 15px 0px rgba(252,91,91,0.5);
  width: 65px;
  height: 80px;
  border-radius: 50px;
  color: #ffffff;
  font-size: 22px;
  margin-bottom: 30px;
  overflow: hidden;
  position: relative;
  transition: all 4s;
}

.item.active {
  box-shadow: 4px 5px 15px 0px rgba(120,91,252,.3);
}

.item.shake {
  animation: shake 2s ease-in-out;
}

.item i {
  z-index: 1;
  animation: iconAnimate 2s ease-in-out infinite;
}

.item--bg {
  opacity: 0;
  background: linear-gradient(321deg, rgba(120,91,252,1) 0%, rgba(159,162,252,1) 100%);
  width: 100%;
  height: 100%;
  position: absolute;
  transition: opacity 4s;
}

.item.active .item--bg {
  opacity: 1;
}

button {
  cursor: pointer;
  background: linear-gradient(321deg, rgba(250,167,64,1) 0%, rgba(247,207,155,1) 100%);
  box-shadow: 4px 4px 8px 0px rgba(245,167,74,0.5);
  color: #ffffff;
  border-width: 0px;
  border-radius: 12px;
  padding: 13px 20px;
  font-family: 'Montserrat', sans-serif;
  font-size: 12px;
  font-weight: bold;
  transition: all .3s ease-in-out;
}

button:hover {
  box-shadow: 4px 4px 8px 0px rgba(245,167,74,0.2);
  transform: translateY(-2px);
}

@keyframes iconAnimate {
  0% { transform: translateY(0px); }
  50% { transform: translateY(5px); }
  100% { transform: translateY(0px); }
}

@keyframes shake {
  0% { transform: translateY(0px); }
  5% { transform: translateY(-2px); }
  10% { transform: translateY(0px); }
  15% { transform: translateY(-5px); }
  20% { transform: translateY(0px); }
  25% { transform: translateY(-7px); }
  30% { transform: translateY(0px); }
  35% { transform: translateY(-9px); }
  40% { transform: translateY(0px); }
  45% { transform: translateY(-10px); }
  50% { transform: translateY(0px); }
  55% { transform: translateY(-10px); }
  60% { transform: translateY(0px); }
  65% { transform: translateY(-10px); }
  70% { transform: translateY(0px); }
  75% { transform: translateY(-10px); }
  80% { transform: translateY(0px); }
  85% { transform: translateY(-10px); }
  90% { transform: translateY(0px); }
  95% { transform: translateY(-10px); }
  100% { transform: translateY(0px); }
}
const change = () => {
  const item = document.querySelector('.item');
  item.classList.toggle('active');
  item.classList.add('shake');
  
  setTimeout(() => item.classList.remove('shake'), 2000);
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.