2012-12-07 49 views
1

嗨,大家好,我有一些代码,这是假设旋转div并使其向上移动。它在除IE以外的所有浏览器中工作。任何帮助都会很棒。jquery旋转不工作在ie

function rotate(degree) { 
    $elie.css({ 
     '-webkit-transform': 'rotate(' + degree + 'deg)', 
     '-moz-transform': 'rotate(' + degree + 'deg)', 
     '-o-transform': 'rotate(' + degree + 'deg)', 
     '-ms-transform': 'rotate(' + degree + 'deg)', 
     'transform': 'rotate(' + degree + 'deg)' 
    }); 
    console.log(degree); 
    if (degree < 55) { 
     timer = setTimeout(function() { 
      rotate(++degree) 
     }, 10) 
}; 

};

+2

什么版本的IE? –

+0

我认为IE浏览器只支持旋转90° –

+0

增量使用ie 9.工作正常铬在那些所以我虽然它将在ie – TheEagle

回答

0

你能告诉你使用的是什么IE浏览器版本吗?你的代码应该可以正常工作了IE9, 试着在你的CSS添加此为IE的其他版本:

filter: progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand', M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476); /* IE6,IE7 */ 
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476)"; /* IE8 */ 

使你的代码应该象下面这样:

function rotate(degree) { 
    $elie.css({ 
     '-webkit-transform': 'rotate(' + degree + 'deg)', 
     '-moz-transform': 'rotate(' + degree + 'deg)', 
     '-o-transform': 'rotate(' + degree + 'deg)', 
     '-ms-transform': 'rotate(' + degree + 'deg)', 
     'transform': 'rotate(' + degree + 'deg)', 
     'filter': 'progid:DXImageTransform.Microsoft.Matrix(sizingMethod="auto expand", M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476)', /* IE7 Note this is the code for 45 degree */ 
     '-ms-filter': "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476)"; /* IE8 Note this is the code for 45 degree */ 
    }); 
    console.log(degree); 
    if (degree < 55) { 
     timer = setTimeout(function() { 
      rotate(++degree) 
     }, 10) 
}; 

引用:

CSS3 transform: rotate; in IE9

CSS rotate property in IE

+0

您好,我在地球上添加这个?和iam使用即9 – TheEagle

+0

这将在CSS代码中;它是IE7/8/9的IE特定代码。但是如果你想支持旧的IE版本,你只需要它;按照他提供的参考链接,IE9应该执行标准的CSS旋转。如果你只是支持IE9,你不需要过滤器。 – Spudley

+0

它不会伤害,如果你添加它,如果你使用IE9和旋转不起作用,那么确保兼容模式没有设置为7或8. –

0

尝试

if($.browser.msie){ 
    $elie.css({ msTransform: 'rotate(' + degree + 'deg)' }); 
}else{ 
    $elie.css({ 
     '-webkit-transform': 'rotate(' + degree + 'deg)', 
     '-moz-transform': 'rotate(' + degree + 'deg)', 
     '-o-transform': 'rotate(' + degree + 'deg)', 
     '-ms-transform': 'rotate(' + degree + 'deg)' 
    }); 
} 
+0

nope dosent work – TheEagle

1

的代码在IE9您的问题提供应该工作。

我可以想到它不工作的唯一原因是如果您的IE9实际上是在IE8兼容模式下呈现。

这实际上是一个很常见的问题(尤其对于开发人员,因为IE默认为本地网络上的站点兼容模式,通常包括您的开发服务器)。

检查时,打开开发工具菜单(F12),然后看右上角;它应该显示你的浏览器模式。如果它说“IE9标准”以外的任何内容,那么你需要纠正它。

  • 选择“工具”菜单,
  • 选择兼容性视图设置:这恼人的默认可如下关闭。
  • 取消选中激活兼容模式的选项。

您可能还需要一个元标记添加到您的网页,迫使IE浏览器使用标准模式下为其他用户:

<meta http-equiv="X-UA-Compatible" content="IE=Edge"/> 

有了这些措施,你的页面应该在IE9标准模式呈现,然后你应该可以使用标准的CSS旋转。

希望有所帮助。

+0

试过这个,还是没有什么:) – TheEagle

+0

你能确认IE9正在使用的渲染模式吗? – Spudley