jquery摇动效果和margin-auto [英] jquery shake effect and margin-auto

查看:123
本文介绍了jquery摇动效果和margin-auto的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有点麻烦...
震动效果示例

在Firefox中如果我省略该行

in firefox if I omit the line

$this.css({'margin-left':$this.position().left});

然后框被动画到左边而不是中心。如果我保留这行代码来修复firefox,那么chrome就会遇到同样的问题。

then the box is animated over to the left instead of in the centre. If I keep that line of code to fix firefox then chrome has the same problem.

任何关于绕过这个问题的提示都会很棒。

Any tips on getting round this would be grand.

提前谢谢

推荐答案

解决方案(不是一个快乐的解决方案,但它可以跨浏览器运行 - 我说跨浏览器,得到了ie9,我的工作机器无法运行虚拟PC !!!!);

the solution (not a happy one but it 'works' cross browser - I say cross browser, got ie9 and my work machine can't run virtual PC!!!!);

var options = {
              direction: 'left',
              distance: 10,
              times: 2
              };
var left = $this.position().left > parseInt($this.css('margin-left')) ? $this.position().left : $this.css('margin-left');
$this
    .css({'margin-left': left})
    .effect('shake' , options , 75 , function(){
        $this.removeAttr('style');
});

这篇关于jquery摇动效果和margin-auto的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆