2011-04-08 107 views
3

只要下面的代码在Chrome和FF(未在其他浏览器中测试过)中运行,"text"就如同在图像中一样。 脚本应该解除上述"text" 4PX上mouseovermouseoutjQuery动画相对位置(悬停时)bug,

但是相反,当鼠标在运动如下带来的,每一次提升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!

注:在上面的图像文本只是一个,显示为理解他人的目的。 你必须快速捕捉同样的效果。

+0

+1良好的格式。 – 2011-04-08 13:33:38

+0

@Soner谢谢:) – 2011-04-08 13:35:52

+0

@Val试试它很快,就像链接周围的旋转运动一样...... – 2011-04-08 14:21:17

回答

2

我想你可以只设置顶部悬停和0像素-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:'0px'},400); 
    }); 
}); 
+0

谢谢,:-)它现在好多了!虽然它仍然升起,但至少它会回到原来的位置 – 2011-04-08 14:17:57

+0

文本是否仍然有可能被限制到特定区域,因此如果试图跨越它,它会弹回到原始位置? – 2011-04-08 14:23:11

+2

您也可以使用类似如下的方式进入css3: '#ca { -webkit-transition:全部0.2s缓出; -moz-transition:全部0.2s缓出; -o-transi重刑:全部0.2秒缓出; -webkit-transition:全部0.2s缓出; 转型:全部0.2s缓出; } #c a:hover {margin-top:-4px;}' – Thorgeir 2011-04-08 14:23:44