我正在寻找在 IE 6-8 中计算旋转 div 的正确值。我从这篇文章JavaScript IE rotation transform maths中获取了以下计算,但它似乎在 IE6 或 7 中不起作用。它在 IE8 中起作用,所以这让我想知道这是否是语法问题。
var angle = 45;
radians = parseInt(angle) * Math.PI * 2 / 360;
calSin = Math.sin(radians);
calCos = Math.cos(radians);
var rotateCSS = 'filter: progid:DXImageTransform.Microsoft.Matrix(M11=' + calCos + ', M12=-' + calSin + ',M21=' + calSin + ', M22=' + calCos + ', sizingMethod="auto expand"); '; /* IE6,IE7 */
rotateCSS += '-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod="auto expand", M11=' + calCos + ', M12=-' + calSin + ', M21=' + calSin + ', M22=' + calCos + ')"; '; /* IE8 */
$('.rotate').attr('style', rotateCSS);