jquery - 如何使用 jquery 使该选项卡具有动画效果?

标签 jquery hover jquery-animate

我希望此选项卡在悬停时具有动画效果

之前:before

悬停时:after

我该如何使用 jquery 来解决这个问题?

<div class="recruiterLink">
<a href="http://mydomain.com/recruiter/">
<span>Recruiting?</span>
<br>
Advertise a vacancy »
</a>
</div>

谢谢!

最佳答案

这可能是您正在寻找的内容的开始:

$(document).ready(function() {

    $('#tab-to-animate').hover(function() {

        // this anonymous function is invoked when
        // the mouseover event of the tab is fired

        // you will need to adjust the second px value to
        // fit the dimensions of your image
        $(this).css('backgroundPosition', 'center 0px');

    }, function() {

        // this anonymous function is invoked when
        // the mouseout event of the tab is fired

        // you will need to adjust the second px value to
        // fit the dimensions of your image
        $(this).css('backgroundPosition', 'center -20px');

    });

});

抱歉误读了这个问题,假设您最初使用position:relative css属性将div向下推,这段代码应该将div作为一个整体移动。

$(document).ready(function() {

    $('.recruiterLink').hover(function() {

        $(this).css({
            'position' : 'relative',
            'top' : 0
        });

    }, function() {

        $(this).css({
            'position' : 'relative',
            'top' : 20
        });

    });

});

关于jquery - 如何使用 jquery 使该选项卡具有动画效果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4244150/

相关文章:

javascript动态添加值到数组

jquery - jqGrid加载所有行,忽略rowNum

javascript - textarea.val() 发送未编辑的原始值

css - 悬停变换时的闪烁效果

css - 如何使用 CSS 在鼠标悬停时向图像添加工具提示

javascript - 通过 onclick 更改背景并阻止悬停

javascript - ASP.NET iframe 有时不更新

jQuery 动画对象看起来像漂浮在水中

jQuery animate(),展开一个 div

jquery - 结合 jQuery 延迟和 windowTimeout 以实现基于 CSS 的淡入淡出