Pulsing Heart CSS animation

前端 未结 7 1060
小蘑菇
小蘑菇 2020-12-12 12:34

I`m working on an animated heart only with CSS.

I want it to pulse 2 times, take a small break, and then repeat it again.

What I have now:

sm         


        
相关标签:
7条回答
  • 2020-12-12 13:15

    I think this is what you want for your image animation. There is no need of top image. Just use bottom.

    #button{
      width:450px;
      height:450px;
      position:relative;
      top:48px;
      margin:0 auto;
      text-align:center;
      }
    #heart img{
      position:absolute;
      left:0;
      right:0;
      margin:0 auto;
     }
    
     @keyframes heartFadeInOut {
      0%
      {    transform: scale( .5 );  }
      20%
      {    transform: scale( 1 );  }
      40%
      {    transform: scale( .5 );  }
      60%
      {    transform: scale( 1 );  }
      80%
      {    transform: scale( .5 );  }
      100%
      {    transform: scale( .5 );  }
    }
    
    #heart img.bottom { 
      animation-name: heartFadeInOut; 
      animation-iteration-count: infinite;
      animation-duration: 1.5s;
      animation-direction: alternate;
    
    }
    <div id="heart" >
      <img class="bottom" src="https://goo.gl/nN8Haf" width="100px">
    </div>

    0 讨论(0)
提交回复
热议问题