Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <head> <style> #DIV1 { height: 200px; width: 200px; margin: auto; border: 1px solid black; } #DIV2 { width: 150px; height: 150px; border: 1px solid black; background-color: coral; -ms-transform: rotate(45deg); /* IE 9 */ -webkit-transform: rotate(45deg); /* Chrome, Safari, Opera */ transform: rotate(45deg); } #DIV2original { position: absolute; width: 150px; height: 150px; border: 1px dashed grey; background-color: lightgrey; opacity: 0.5; } </style> </head> <body> <p>Click the "Try it" button to set the origin of the rotation to 0 for both the x-axis and the y-axis:</p> <p><b>Note: </b>The grey DIV element indicates where the DIV2 element would be without the transformation.</p> <button onclick="myFunction()">Try it</button> <div id="DIV1">DIV1 <div id="DIV2original">DIV2</div> <div id="DIV2">DIV2</div> </div> <script> function myFunction() { // Code for Chrome, Safari, Opera document.getElementById("DIV2").style.WebkitTransformOrigin = "0 0"; // Code for IE9 document.getElementById("DIV2").style.msTransformOrigin = "0 0"; document.getElementById("DIV2").style.transformOrigin = "0 0"; } </script> <p><b>Note:</b> Internet Explorer 8 and earlier versions do not support the transformOrigin property.</p> <p><b>Note:</b> Internet Explorer 9 supports an alternative, the msTransformOrigin property. Newer versions of IE support the transformOrigin property (do not need the ms prefix)</p> <p><b>Note:</b> Chrome, Safari and Opera supports an alternative, the WebkitTransformOrigin property.</p> </body> <!-- Mirrored from www.w3schools.com/cssref/tryit.asp?filename=trycss3_js_transform-origin by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 07:53:38 GMT --> </html>
Result:
Try it Yourself - © w3schools.com