首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Animate.css动画不工作

Animate.css动画不工作
EN

Stack Overflow用户
提问于 2014-01-02 23:10:31
回答 1查看 835关注 0票数 0

我目前使用的是Animate.css框架。我想做一个我已经创建的小条,当我每次悬停在图像上时,它可以简单地在页面上移动几个像素。以下是图像和小条形图的代码:

代码语言:javascript
复制
<div id="GoogleBar" class="bar"  style="position:fixed;bottom:5%;left:33.8%;">
    <center>Google +</center>
</div>
<a href="http://www.google.com"><img id="Google" src="css/images/Google_PlusBook.png" style="width:5.9%;height:15%;position:fixed;bottom:3.2%;left:33.2%;padding:4px;"></a>

栏的Css:

代码语言:javascript
复制
.bar
{
    background: #000000;
    width: 5%;
    height: 3%;
    color:#ffffff;
    line-height: 150%;
    border:1px solid #ffffff;
    border-radius:25px;     
    font-family: Arial;
} 

当我将鼠标悬停在图像上时,下面是我用来添加动画类的代码:

代码语言:javascript
复制
$(document).ready(function() 
        {     
            $('#Google').hover(function()
            {     
                $('#GoogleBar').removeClass('animated bounceInDown');
                $('#GoogleBar').addClass('animated bounceInUp');  
            },     
            function()
            {    
                $('#GoogleBar').removeClass('animated bounceInUp');  
                $('#GoogleBar').addClass('animated bounceInDown');    
            });
        }); 

现在我知道类正在被添加到栏中,因为我在浏览器中检查了它,但由于某些原因,栏不能在屏幕上上下移动。我真的不知道为什么它不能工作

EN

回答 1

Stack Overflow用户

发布于 2014-01-02 23:35:55

尝试使用setTimeout()函数,因为我认为你同时添加和删除了类,导致效果没有时间生效。:

代码语言:javascript
复制
$(document).ready(function() 
        {     
            $('#Google').mouseenter(function()
            {     
                $('#GoogleBar').removeClass('animated bounceInDown');
                $('#GoogleBar').addClass('animated bounceInUp');  

                setTimeout(function() {
                   $('#GoogleBar').removeClass('animated bounceInUp');  
                   $('#GoogleBar').addClass('animated bounceInDown'); 
                },1000);
            });
        }); 

另外,在mousenter()中添加类之后,还可以添加mouseout()处理程序来更改类。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20885849

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档