Анимируйте прямоугольник в форме половины сердца, используя css - PullRequest
0 голосов
/ 02 мая 2020

Анимация перемещает фигуру сначала вниз, а затем влево, вместо того, чтобы идти по диагонали. Я ошибаюсь во времени анимации или, возможно, в расположении элементов. Я понимаю, что это просто анимация форм, которые уже были описаны во многих постах. Я нахожу это сложным с анимацией формы с помощью псевдоэлемента. Ценю помощь.

.container {
  background-color: black;
  height: 500px;
  width: 300px;
  margin: 0 auto;
  position: relative;
}

.firsthalf
/* this is going to turn into the bottom of the half heart shape */

{
  height: 0px;
  width: 0px;
  position: absolute;
  margin: auto;
  right: 0px;
  top: 25px;
  border: 25px solid green;
  animation-name: heart-bottom1;
  animation-duration: 3s;
}

@keyframes heart-bottom1 {
  0% {
    top: 25px;
    right: 0px;
    border-radius: 25px solid green;
  }
  50% {
    border-bottom: 25px solid transparent;
    border-right: 25px solid transparent;
    top: 200px;
    left: 100px;
  }
  100% {
    top: 25px;
    right: 0px;
  }
}

.firsthalf::before
/*this is going to turn into the upper part(the spherical bit) of the half 
      heart*/

{
  content: "";
  background-color: green;
  height: 25px;
  width: 50px;
  position: absolute;
  bottom: 25px;
  left: -25px;
  animation-name: heart-up1;
  animation-duration: 3s;
}

@keyframes heart-up1 {
  0% {
    height: 25px;
    width: 50px;
    border-radius: 0;
  }
  50% {
    border-radius: 25px 25px 0 0;
  }
  100% {
    border-radius: 0;
    height: 25px;
    width: 50px;
  }
}
<div class="container">
  <div class="firsthalf">
  </div>
</div>
...