【发布时间】:2016-04-18 03:37:34
【问题描述】:
我正在使用 CSS 制作一个动画心脏。
我希望它脉搏 2 次,稍作休息,然后再重复一次。
我现在拥有的:
small ==> big ==> small ==> repeat animation
我要做什么:
small ==> big ==> small ==> big ==> small ==> pause ==> repeat animation
我该怎么做?
我的代码:
#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;
-webkit-transition: opacity 7s ease-in-out;
-moz-transition: opacity 7s ease-in-out;
-o-transition: opacity 7s ease-in-out;
transition: opacity 7s ease-in-out;}
@keyframes heartFadeInOut {
0% {
opacity:1;
}
14% {
opacity:1;
}
28% {
opacity:0;
}
42% {
opacity:0;
}
70% {
opacity:0;
}
}
#heart img.top {
animation-name: heartFadeInOut;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
animation-duration: 1s;
animation-direction: alternate;
}
<div id="heart" >
<img class="bottom" src="https://goo.gl/nN8Haf" width="100px">
<img class="top" src="https://goo.gl/IIW1KE" width="100px">
</div>
另见this Fiddle。
【问题讨论】:
-
您使用 jsfiddle 而不是问题中集成的 Stack Snippet 有什么原因吗?据我所知,堆栈片段适用于您的示例。