是否可以将CSS3动画停留在75%并且不应该再次显示为0%或至少使延迟为75%持续10秒?现在,当动画完成时,它显示在0%位置
div {
width: 100px;
height: 100px;
background-color: red;
position: relative;
-webkit-animation-name: example;
/* Chrome, Safari, Opera */
-webkit-animation-duration: 4s;
/* Chrome, Safari, Opera */
animation-name: example;
animation-duration: 4s;
}
/* Chrome, Safari, Opera */
@-webkit-keyframes example {
0% {
background-color: red;
left: 0px;
top: 0px;
}
25% {
background-color: yellow;
left: 200px;
top: 0px;
}
50% {
background-color: blue;
left: 200px;
top: 200px;
}
75% {
background-color: green;
left: 0px;
top: 200px;
}
}
<div></div>
答案 0 :(得分:0)
我对您的动画进行了一些更改,您需要做的就是复制75%
动画两次,然后使用animation-fill-mode
属性并将其设置为forwards
以停止动画在最后一个位置。
div {
width: 100px;
height: 100px;
background-color: red;
position: relative;
-webkit-animation-name: example; /* Chrome, Safari, Opera */
-webkit-animation-duration: 4s; /* Chrome, Safari, Opera */
animation-name: example;
animation-duration: 4s;
/* add these properties */
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards;
}
/* Chrome, Safari, Opera */
@-webkit-keyframes example {
0% {background-color:red; left:0px; top:0px;}
25% {background-color:yellow; left:200px; top:0px;}
50% {background-color:blue; left:200px; top:200px;}
75% {background-color:green; left:0px; top:200px;}
/* add the below one */
100% {background-color:green; left:0px; top:200px;}
}