我能够为所有浏览器设置CSS旋转设置,但现在我需要在Javascript中执行此操作。 我也在使用jQuery,目前还有以下内容:
.css({ '-ms-filter':"progid:DXImageTransform.Microsoft.Matrix(M11=0.9659258262890683, M12=-0.2588190451025207, M21=0.2588190451025207, M22=0.9659258262890683, SizingMethod='auto expand')" });
无效。 CSS中的相同代码完美无缺。我试过逃避撇号,但它没有用。有任何想法吗?我首先需要设置最初的值,所以只需要一个简单的.CSS如上所示。然后在以下函数中更新值:
function rotate(degree){
if((ievers==6)||(ievers==7)||(ievers==8)){
current_obj.css({
/* IE8 */
'-ms-filter':'"progid:DXImageTransform.Microsoft.BasicImage(rotation='+degree+')"',/* IE<8 */'filter':'progid:DXImageTransform.Microsoft.BasicImage(rotation='+degree+')'});
} else {
/* HANDLE OTHER BROWSERS */ ...
};
rotatetimer = setTimeout(function(){ rotate(++degree); },10 );}
此代码已设置并可在除IE7 / 8之外的所有内容中工作(因为(rotation = x)只允许4个旋转选项。所以我试图将该行与.Matrix交换并动态计算SIN / COS值即时。
答案 0 :(得分:1)
current_obj [0] .style.filter =“progid:DXImageTransform.Microsoft.Matrix(M11 = 0.9659258262890683,M12 = -0.2588190451025207,M21 = 0.2588190451025207,M22 = 0.9659258262890683,SizingMethod ='auto expand')”;
为我工作。另外,正如我所见,BasicImage滤镜的旋转值以90度的增量进行测量。有关过滤器的更多参考资料:MSDN filters