jQuery动画遇到悬停效果

jQuery动画遇到悬停效果

问题描述:

我想让鼠标悬停在上面的图像再次向下移动,当我不再徘徊时。我能够使用CSS3来实现这种效果,但由于并非所有的浏览器都支持它,我也希望能够使用jQuery。我创建了一个捣鼓你:http://jsfiddle.net/fSthA/2/jQuery动画遇到悬停效果

这里是我的jQuery代码:

$('.full-circle').mouseOver(
    function(){ 
     $(this).stop().animate(
      {margin-top: '2'}, 500, 'swing' 
     );//end animate 
    },//end function 
    function(){ 
     $(this).stop().animate(
      {margin-top: '15'}, 500, 'swing' 
     );//end animate 
    }//end function 
);//end hover 
+1

你有什么问题吗? – Brandon 2013-04-08 02:01:29

我不知道你的问题是什么,但我修改你的提琴通过jQuery做。我不得不删除CSS过渡,在:hover风格,添加了jQuery小提琴,改变你的animate调用中使用marginTop,而不是margin-top

$('.full-circle').hover(
    function(){ 
     $(this).stop().animate(
      {marginTop: '2'}, 500, 'linear' 
     );//end animate 
    },//end function 
    function(){ 
     $(this).stop().animate(
      {marginTop: '15'}, 500, 'linear' 
     );//end animate 
    }//end function 
);//end hover 

http://jsfiddle.net/fSthA/5/

+0

将颜色更改为红色:http://jsfiddle.net/basarat/fSthA/8/,因此该圆实际上可见而不会眯眼:D – basarat 2013-04-08 02:32:27