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 */
    /* Chrome, Safari, Opera */
    -webkit-transform: rotate(45deg);
    -webkit-animation: mymove 5s infinite;
    /* Standard syntax */
    transform: rotate(45deg);
    animation: mymove 5s infinite;
}


/* Chrome, Safari, Opera */
@-webkit-keyframes mymove {
    50% {-webkit-transform-origin: 0 0 0;}

}

/* Standard syntax */
@keyframes mymove {
    50% {transform-origin: 0 0 0;}

}

#DIV2original {
    position: absolute;
    width: 150px;
    height: 150px;
    border: 1px dashed grey;
    background-color: lightgrey;
    opacity: 0.5;
}

</style>
</head>
<body>

<p>Gradually change the transform-origin from "50% 50% 0" to "0 0 0", and back:<p>
<p><b>Note: </b>The grey DIV element indicates where the DIV2 element would be without the transformation.</p>

<div id="DIV1">DIV1
  <div id="DIV2original">DIV2</div> <div id="DIV2">DIV2</div>
</div>

<p>The transform-origin property is <em>animatable</em> in CSS.</p>
<p><strong>Note:</strong> CSS Animations do not work in Internet Explorer 9 and earlier versions.</p>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy