css3动画暂停在屏幕中间

时间:2014-04-01 09:33:27

标签: css3

基本上这是一个球。 这个球从左到右。 我希望球在到达屏幕中间时暂停,3秒后它会淡出正确 我该怎么做?

div.new-goal {
    position:absolute;
    margin-top: 30px;
    background-color: transparent;
    text-align:center;
    -webkit-animation: movein 1.0s ease-out 0s 1, moveout 2.1s ease-in 1s 1;
    -webkit-animation-fill-mode: forwards;
    white-space: nowrap;
    color: $green2;
}

ps:它的SASS

1 个答案:

答案 0 :(得分:1)

<强> HTML

<div id="ball"></div>

<强> CSS

body {
    margin: 0;
    padding: 0;
}

#ball {
    width: 50px;
    height: 50px;
    background: green;
    border-radius: 50%;
    position: absolute;
    left: -50px;
    -webkit-animation: move 8s;
    -webkit-animation-fill-mode: forwards;
}

@-webkit-keyframes move
{ /* 
    8s : 100% = 3s : x 
    x = 37.5%
    */
    37.5% {
        left: calc(50% - 25px); opacity: 1;
    }
    75% {
        left: calc(50% - 25px); opacity: 1;
    }
    85% {
        left: 80%; opacity: 0;
    }
    100% {
        opacity: 0;
    }
}

http://jsfiddle.net/8B9Lx/3/