css3不同状态的不同关键帧

标签 css hover css-animations

我遇到了一些麻烦 我的第一个动画在页面加载时工作正常,但我想在你将鼠标悬停在图形元素上时触发另一个动画,如果你这样做,第一个动画会重复,但显然,如果你将鼠标放在红色框上并强制它转到原来的位置,然后我的第二个动画工作:/

对于关键帧,元素是否属于它的第一个位置?我把它绝对化了,是一回事。 您可以在此处查看工作代码: http://jsfiddle.net/zhk7w/ 谢谢你的手!

<div id="wrapper">
        <article>
            <div id="sharing-wrapper">
                <figure>
                <a class="animate" href="#">p</a>
                </figure>

            </div>
            <div class="test">
                <a class="test" href="">C</a>
            </div>
        </article>
    </div>

和CSS:

#sharing-wrapper figure{
margin-left: 50px;
position: relative;
width: 20px;
height: 20px;
}
#sharing-wrapper figure{
padding: 15px;
background-color: red;
position: relative;
-webkit-animation-name:animatetopbottom,animateleft;
-webkit-animation-duration:3s,3s;
-webkit-animation-fill-mode:forwards;
/*-webkit-animation-direction:alternate;*/
}
#sharing-wrapper figure:hover{
-webkit-animation: shakeit 1s;}

动画:

    @-webkit-keyframes animateleft{
    from {left: 0px;}
    to {left: 50px;}
}

@-webkit-keyframes animatetopbottom{
    0% {top: 0px;}
    10% {top: 90px;}
    20% {top: 60px;-webkit-transform:rotate(680grad);}
    30% {top: 90px;-webkit-transform:scale(0.7);}
    40% {-webkit-transform:scale(1.5);}
    50% {top: 60px;-webkit-transform:rotate(0grad);}
    80% {top: 80px;}
    100% {top: 80px;}

}



    @-webkit-keyframes shakeit{
    from { top: 25px; }
    to { top: -40px; }
    }

最佳答案

你应该在他们悬停之前给动画一个延迟。

一旦你悬停你的盒子,它就会离开鼠标并且 :hover 不再是事件状态,next 或 defaut 动画会立即接管: http://jsfiddle.net/zhk7w/1/

#sharing-wrapper figure{
    padding: 15px;
    background-color: red;
    position: relative;
    -webkit-animation-delay:1s;
    -webkit-animation-name:animatetopbottom,animateleft;
    -webkit-animation-duration:3s,3s;
    -webkit-animation-fill-mode:forwards;
    /*-webkit-animation-direction:alternate;*/
}

关于css3不同状态的不同关键帧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17138107/

相关文章:

javascript - border-radius Angular 落里的事件

css - 如何使用库 cssanimation.io 设置延迟

html - CSS 动画在 Chrome 中不起作用

javascript - CDN 可以更快地加载资源吗?

jquery - 使 div 在每个浏览器中都可旋转

html - css hover 不起作用(小代码)

javascript - CSS 滚球动画位置

javascript - Polymer 不允许在 Chrome 中设置内部元素的样式和传播事件

html - CSS 问题,除非填满文本,否则 Col 不会留在原地

jquery - 如何使我的悬停标题覆盖整个图像大小?