Here is the full CSS stylesheet you need to get all current browsers to rotate an element. I've commented the styles with the relevant browsers that they affect.
.myclass {
-ms-transform: rotate(45deg); /* IE9 ? */
-moz-transform: rotate(45deg); /* FF3.5+ */
-o-transform: rotate(45deg); /* Opera 10.5 */
-webkit-transform: rotate(45deg); /* Saf3.1+, Chrome */
transform: rotate(45deg); /* CSS3 (for when it gets supported) */
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 */
}
This example rotates an element by 45 degrees. The IE6/7/8 filter
and -ms-filter
styles use radians instead of degrees.
The other big difference between the filter
styles and the others is the origin point of the rotation. If I recall correctly, the transform
styles rotate around the center while the MS styles rotate around the top left corner. I believe this can be adjusted, but we solved this issue just by having an IE-only style that shifted the absolute position of the element so it ended up in the same place. Obviously this won't help you when it comes to an animation though.
The final thing to point out is that the IE6/7 filter
style is actually invalid CSS (because it contains colons and other reserved characters). The -ms-filter
variant for IE8 is okay because it is in quotes, but this isn't allowed in the IE6/7 version. This problem actually breaks CSS parsing in Firefox (and possibly other browsers), to the point that any subsequent styles will not be read. For this reason, I recommend that you include it (or at least the IE-specific parts) in its own stylesheet.