gpt4 book ai didi

javascript - jQuery 动画相对位置(悬停时)错误,

转载 作者:行者123 更新时间:2023-11-29 15:04:13 25 4
gpt4 key购买 nike

每当以下代码在 Chrome 和 FF 中运行时(未在其他浏览器中测试),"text" 都会像图片中那样显示。该脚本应该在 mouseover 上将 "text" 提升 4px,并在 mouseout

上将其返回

但相反,当鼠标如下图所示移动时,每次它向上抬起 4px 到最后一个位置。

$(document).ready(function(){
$('#n #c a').hover(function(){
$('span',this).stop(true,true).animate({top:'-=4px'},200);
},function(){
$('span',this).stop(true,true).animate({top:'+=4px'},400);
});
});

Follow the steps as such, it should be quick!

注意:在上图中,文字只是一个,其他文字是为了理解目的而显示的。您必须快速捕捉到相同的效果。

最佳答案

我认为你可以在悬停时将顶部设置为 -4px,当鼠标存在时将顶部设置为 0px

$(document).ready(function(){
$('#n #c a').hover(function(){
$('span',this).stop(true,true).animate({top:'-4px'},200);
},function(){
$('span',this).stop(true,true).animate({top:'0px'},400);
});
});

关于javascript - jQuery 动画相对位置(悬停时)错误,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5595791/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com