Day # 52: Beating heart



I have always stated that animations represent a great resource to learn and practice CSS fundamentals. They have a certain amount of enjoyment that makes the learning process more effective.

That being said, I figured I could create a cool animation for today’s website. In this case, the project consists of a beating heart.

Firstly, we need to take care of creating the heart:

.heart {

  position: relative;

  width: 200px;

  height: 200px;

  background: #e80202;

  transform: rotate(45deg);

  box-shadow: 30px 30px 200px rgba(0, 0, 0, 0.5);

  animation: animate 1s linear infinite;

}


Secondly, we need to take care of the animation itself. By just focusing on the transform property on its rotate and scale values, we’ll have the work done!

@keyframes animate {

  0% {

    transform: rotate(45deg) scale(1);

  }

  20% {

    transform: rotate(45deg) scale(0.8);

  }

  40% {

    transform: rotate(45deg) scale(1.2);

  }

  60% {

    transform: rotate(45deg) scale(1.3);

  }

  80% {

    transform: rotate(45deg) scale(1);

  }

  100% {

  }

}


Comments

Popular posts from this blog

Day # 19: Checkbox animation

Day # 12: Typewriter Effect

Day # 53: Icon text