Skip to content

Instantly share code, notes, and snippets.

@ogorzalka
Created May 2, 2011 12:46
Show Gist options
  • Save ogorzalka/951550 to your computer and use it in GitHub Desktop.
Save ogorzalka/951550 to your computer and use it in GitHub Desktop.
Cross Browser rotation with lessjs
.rotate(@deg: 0){
@degree: @deg;
@rotation: `parseInt(this.degree.toJS())`;
@degToRadian: `Math.PI * 2 / 360`;
@rad: `this.rotation.toJS() * this.degToRadian.toJS()`;
@M11: `Math.cos(this.rad.toJS())`;
@M21: `Math.sin(this.rad.toJS())`;
// the properties
-moz-transform: rotate(@deg);
-webkit-transform: rotate(@deg);
-o-transform: rotate(@deg);
transform: rotate(@deg);
filter: e(%("progid:DXImageTransform.Microsoft.Matrix(M11=%d, M12=-%d, M21=%d, M22=%d)", @M11, @M21, @M21, @M11));
}
.my-elem {
.rotate(90deg);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment