jQuery mouse Out调用CSS3 Animation

时间:2012-08-31 18:26:07

标签: javascript jquery css3

我目前有鼠标悬停事件的CSS3动画,请参见下文:

#topo .menu-header ul li:hover a {
    -webkit-animation: menuanimate 0.3s linear 0s both;
    -moz-animation: menuanimate 0.3s linear 0s both;
    -o-animation: menuanimate 0.3s linear 0s both;
    -ms-animation: menuanimate 0.3s linear 0s both;
    animation: menuanimate 0.3s linear 0s both;
}
@-webkit-keyframes menuanimate{
    50% {
        transform: rotateY(90deg);
        -webkit-transform: rotateY(90deg); /* Safari and Chrome */
        -moz-transform: rotateY(90deg); /* Firefox */
        color: #353535; 
        background: url(images/bullets.png) no-repeat;
        background-position: 3px 18px;
    }
    51% {
        transform: rotateY(270deg);
        -webkit-transform: rotateY(270deg); /* Safari and Chrome */
        -moz-transform: rotateY(270deg); /* Firefox */
        color: #fff;
        background: #f15a25;
    }
    100% { 
        color: #fff; background: #f15a25;
        transform: rotateY(360deg);
        -webkit-transform: rotateY(360deg); /* Safari and Chrome */
        -moz-transform: rotateY(360deg); /* Firefox */
    }
}

问题是:当用户将鼠标从按钮移开时,没有动画。在CSS中没有鼠标输出事件,那么,有没有办法在jQuery中调用鼠标输出的动画?

提前多多感谢。

1 个答案:

答案 0 :(得分:1)

你不能只用jQuery调用它:

$('element').hover(function(e)
{
     $(this).css({"rollover animation css in here..."});
},function(e)
{
     $(this).css({"rolloff animation css in here..."});
});

或者甚至只有2个类“.over”和“.out”,然后使用$(this).addClass(“over”)&滚出时也一样吗?