CSS Properties: How to set a rotated element's base placement

Go to Exercise page


HTML Code :

 <!DOCTYPE html>
  <title>How to set a rotated element's base placement</title>
  <style type="text/css">
  #div1 {
    position: relative;
    height: 100px;
    width: 100px;
    margin: 50px;
    padding: 10px;
    border: 2px solid #CC0099;

#div2 {
    padding: 18px;
    position: absolute;
    border: 1px solid #990000;
    background-color: #0000CC;
    -ms-transform: rotate(30deg);
    -ms-transform-origin: 20% 30%;
    -webkit-transform: rotate(30deg);
    -webkit-transform-origin: 20% 30%;
    transform: rotate(30deg);
    transform-origin: 20% 15%;
  <h1><strong>w3resource Tutorial</strong></h1>
<div id="div1"> <div id="div2">Web Development Tutorial</div> </div> </body> </html>

Live Demo:

See the Pen transform-origin-answer by w3resource (@w3resource) on CodePen.

See the solution in the browser

Supported browser

Firefox logo Chrome logo Opera logo Safari logo Internet Explorer logo

Go to Exercise page

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.

Follow us on Facebook and Twitter for latest update.