I came across some animation code on the web and noticed that when I click the image, it replays the animation from the starting point. I want to make it so that when I click the image, the animation plays and stops, and if clicked again, resets the image. Can anyone provide feedback on how to achieve this?
.like-btn-svg {
width: 80px;
height: 100px;
position: absolute;
left: 25px;
bottom: -112px;
transform: translate(-50%, -50%);
background: url(https://abs.twimg.com/a/1446542199/img/t1/web_heart_animation.png) no-repeat;
background-position: 0 0;
animation: fave-like-btn-svg 1s steps(28);
cursor: pointer;
}
.like-btn-svg:hover {
background-position: -2800px 0;
transition: background 1s steps(28);
}
@keyframes fave-like-btn-svg {
0% {
background-position: 2800px 0;
}
100% {
background-position: -2800px 0;
}
}
<div class="like-btn-svg"></div>