CSS动画跳过

时间:2016-07-02 13:39:56

标签: css animation

这是我的CSS代码:

#case {
    background-position: -0px 0px;
    -webkit-animation-name: example; /* Chrome, Safari, Opera */
    -webkit-animation-duration: 5s; /* Chrome, Safari, Opera */
    animation-name: example;
    animation-duration: 5s;
}

/* Chrome, Safari, Opera */
@-webkit-keyframes example {
    0% {background-position: -0px 0px;}
    25% {background-position: -1050px 0px;}
    50% {background-position: -0px 0px;}
    75% {background-position: -1050px 0px;}
    100% {background-position: -1050px 0px;}
}

/* Standard syntax */
@keyframes example {
    0% {background-position: -0px 0px;}
    25% {background-position: -1050px 0px;}
    50% {background-position: -0px 0px;}
    75% {background-position: -1050px 0px;}
    100% {background-position: -1050px 0px;}
}

我需要的是动画播放,而不会在完成后返回第一个关键帧。

2 个答案:

答案 0 :(得分:0)

尝试:

#case {
    background-position: -0px 0px;
    -webkit-animation-name: example; /* Chrome, Safari, Opera */
    -webkit-animation-duration: 5s; /* Chrome, Safari, Opera */
    animation-name: example;
    animation-duration: 5s;
}
/* Chrome, Safari, Opera */
@-webkit-keyframes example {
    0% {background-position: -0px 0px;}
    100% {background-position: -1050px 0px;}
}

/* Standard syntax */
@keyframes example {
    0% {background-position: -0px 0px;}
    100% {background-position: -1050px 0px;}
}

答案 1 :(得分:0)

您正在寻找animation-fill-mode,专门设置为forwards

-webkit-animation-fill-mode: forwards; /* Safari 4.0 - 8.0 */
animation-fill-mode: forwards;