Javascript jquery旋转在ie中不起作用

Javascript jquery旋转在ie中不起作用,javascript,jquery,internet-explorer,rotation,Javascript,Jquery,Internet Explorer,Rotation,嗨,伙计们,我得到了一些代码,可以旋转一个div,让它向上移动。它可以在除IE以外的所有浏览器中工作。任何帮助都会很好 function rotate(degree) { $elie.css({ '-webkit-transform': 'rotate(' + degree + 'deg)', '-moz-transform': 'rotate(' + degree + 'deg)', '-o-transform': 'rotate(

嗨,伙计们,我得到了一些代码,可以旋转一个div,让它向上移动。它可以在除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)
};
函数旋转(度){
$elie.css({
“-webkit变换”:“旋转(“+degree+”deg)”,
“-moz变换”:“旋转(“+degree+”deg)”,
“-o变换”:“旋转(“+度+”度)”,
“-ms变换”:“旋转(“+度+”度)”,
“变换”:“旋转(“+度+”度)”
});
控制台日志(度);
如果(度<55){
计时器=设置超时(函数(){
旋转(++度)
}, 10)
};

})

您能告诉我您使用的IE浏览器版本吗?您的代码在IE9中应该可以正常工作, 尝试将此添加到其他版本IE的css中:

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)
};
函数旋转(度){
$elie.css({
“-webkit变换”:“旋转(“+degree+”deg)”,
“-moz变换”:“旋转(“+degree+”deg)”,
“-o变换”:“旋转(“+度+”度)”,
“-ms变换”:“旋转(“+度+”度)”,
“变换”:“旋转(“+度+”度)”,
“过滤器”:“progid:DXImageTransform.Microsoft.Matrix(sizingMethod=“auto expand”,M11=0.7071067811865476,M12=-0.7071067811865475,M21=0.7071067811865475,M22=0.7071067811865476)”,请注意,这是45度的代码*/
“-ms过滤器”:“progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand',M11=0.7071067811865476,M12=-0.7071067811865475,M21=0.7071067811865475,M22=0.7071067811865476)”;/*IE8注意这是45度的代码*/
});
控制台日志(度);
如果(度<55){
计时器=设置超时(函数(){
旋转(++度)
}, 10)
};
参考资料:


您能告诉我您使用的是什么IE浏览器版本吗?您的代码在IE9上应该可以正常工作, 尝试将此添加到其他版本IE的css中:

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)
};
函数旋转(度){
$elie.css({
“-webkit变换”:“旋转(“+degree+”deg)”,
“-moz变换”:“旋转(“+degree+”deg)”,
“-o变换”:“旋转(“+度+”度)”,
“-ms变换”:“旋转(“+度+”度)”,
“变换”:“旋转(“+度+”度)”,
“过滤器”:“progid:DXImageTransform.Microsoft.Matrix(sizingMethod=“auto expand”,M11=0.7071067811865476,M12=-0.7071067811865475,M21=0.7071067811865475,M22=0.7071067811865476)”,请注意,这是45度的代码*/
“-ms过滤器”:“progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand',M11=0.7071067811865476,M12=-0.7071067811865475,M21=0.7071067811865475,M22=0.7071067811865476)”;/*IE8注意这是45度的代码*/
});
控制台日志(度);
如果(度<55){
计时器=设置超时(函数(){
旋转(++度)
}, 10)
};
参考资料:

试试看

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)'
    });
}
试一试


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

我能想到的唯一不起作用的原因是,如果你的IE9实际上是在IE8兼容模式下渲染的

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

要进行检查,请打开“开发工具”菜单(F12),并查看右上角;它应该会显示浏览器模式。如果它显示的不是“IE9标准”,则需要更正它。此恼人的默认设置可以按如下方式关闭:

  • 选择“工具”菜单
  • 选择兼容性视图设置
  • 取消勾选激活兼容模式的选项
您可能还希望向页面添加元标记,以强制IE对其他用户使用标准模式:

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

有了这些措施,您的页面应该以IE9标准模式呈现,然后您应该能够使用标准CSS旋转


希望有帮助。

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

我能想到的唯一不起作用的原因是,如果你的IE9实际上是在IE8兼容模式下渲染的

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

要进行检查,请打开“开发工具”菜单(F12),并查看右上角;它应该会显示浏览器模式。如果它显示的不是“IE9标准”,则需要更正它。此恼人的默认设置可以按如下方式关闭:

  • 选择“工具”菜单
  • 选择兼容性视图设置
  • 取消勾选激活兼容模式的选项
您可能还希望向页面添加元标记,以强制IE对其他用户使用标准模式:

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

有了这些措施,您的页面应该以IE9标准模式呈现,然后您应该能够使用标准CSS旋转


希望能有所帮助。

我认为IE仅支持使用IE 9以90°的增量旋转。在chrome中效果很好,所以我认为它可以在chrome中工作ie@MikeChristensen-IE6/7/8能够进行任何角度的旋转,而不仅仅是90度。它有一个单独的过滤器,用于90度增量,更易于使用,但它也可以进行任何其他角度的旋转。它是一个ri工作起来很痛苦,它有一些可怕的错误,但它可以做到。@AliBOOM-你检查过你的IE9是在IE9模式下,而不是在IE8兼容模式下。你提供的代码应该在IE9模式下工作,但兼容模式会破坏它。@Spudley-啊,是的,我想我简要地记得曾经研究过它-但我放弃了它,因为它这样做了我有点傻,比如把PNG alpha通道搞砸了……我想IE只支持增量旋转