How to move to the certain keyframe in CSS3 animation?

后端 未结 1 1661
萌比男神i
萌比男神i 2021-01-12 05:51

Let\'s say we have an animation like here: http://jsfiddle.net/utterstep/JPDwC/

Layout:

back
&l
相关标签:
1条回答
  • 2021-01-12 06:00

    Perhaps you have got the answer in CSS+JS

    Please refer Old Post

    Here on fiddle from the same post Fiddle

    And with CSS only here is the Fiddle I have tweaked with :hover property,

    @-webkit-keyframes someanimation {
        0% {
            width: 100px;
        }
        50% {
            width: 200px;
        }
        100% {
            width: 100px;
        }
    }
    
    @-moz-keyframes someanimation {
        0% {
            width: 100px;
        }
        50% {
            width: 200px;
        }
        100% {
            width: 100px;
        }
    }
    
    @keyframes someanimation {
        0% {
            width: 100px;
        }
        50% {
            width: 200px;
        }
        100% {
            width: 100px;
        }
    }
    
    
    
    @-webkit-keyframes someani2 {
        0%,100% {
            width: 100px;
        }
        50% {
            width: 200px;
        }
    }
    
    @-moz-keyframes someani2 {
        0%,100% {
            width: 100px;
        }
        50% {
            width: 200px;
        }
    }
    
    @keyframes someani2 {
        0%,100% {
            width: 100px;
        }
        50% {
            width: 200px;
        }
    }
    
    
    
    .animating {
        width: 200px;
        height: 200px;
        background-color: red;
        -webkit-animation: someanimation 5s infinite;
        -moz-animation: someanimation 5s infinite;
        animation: someanimation 5s infinite;
    }
    .animating:hover{
        color:#f60;
        -webkit-animation: someani2 6s 1;
        -moz-animation: someani2 6s 1;
        animation: someani2 6s 1;
    }
    <div>back</div>
    <div class="animating"></div>
    <div>forward</div>

    it changes the animation on hover, just like back button.

    I hope this will solve your purpose..

    0 讨论(0)
提交回复
热议问题