Edit This Code:
<!DOCTYPE html>
<html>
<head>
<style>
#div1 {
    position: relative;
    height: 200px;
    width: 200px;
    margin: 100px;
    padding: 10px;
    border: 1px solid black;
}


#div2 {
    padding: 50px;
    position: absolute;
    border: 1px solid black;
    background-color: red;
    -ms-transform: rotate(45deg); /* IE 9 */
    -ms-transform-origin: 20% 40%; /* IE 9 */
    -webkit-transform: rotate(45deg); /* Chrome, Safari, Opera */
    -webkit-transform-origin: 20% 40%; /* Chrome, Safari, Opera */
    transform: rotate(45deg);
    transform-origin: 20% 40%;
}

</style>
</head>
<body>

<div id="div1">
  <div id="div2">HELLO</div>
</div>

<p><b>Note:</b> Internet Explorer 8 and earlier versions do not support the transform-origin property.</p>

<p><b>Note:</b> Internet Explorer 9 supports an alternative, the -ms-transform-origin property. Newer versions of IE support the transform-origin property (do not need the ms prefix).</p>

<p><b>Note:</b> Chrome, Safari and Opera supports an alternative, the -webkit-transform-origin property.</p>

</body>
</html>


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