CSS rotate transform - left and top issue - HTML CSS CSS Animation

HTML CSS examples for CSS Animation:Rotate

Description

CSS rotate transform - left and top issue

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
.container {<!-- w w w .ja v  a 2  s  .  c  om-->
   width:51%;
   float:left;
}

.parent {
   width:100px;
   margin:4em;
   padding:3em;
   transform:rotate(46deg);
   -ms-transform:rotate(46deg);
   -webkit-transform:rotate(46deg);
   background-color:Chartreuse;
}

.child {
   background-color:yellow;
   position:absolute;
   padding:2em;
   transform:rotate(-46deg);
   -ms-transform:rotate(-46deg);
   -webkit-transform:rotate(-46deg);
}

.fake_child {
   width:100px;
   background-color:blue;
   padding:2em;
   margin:4em;
   position:relative;
}

.fake_parent {
   position:absolute;
   width:100%;
   height:201%;
   background-color:pink;
   top:0;
   left:0;
   transform:rotate(46deg);
   -ms-transform:rotate(46deg);
   -webkit-transform:rotate(46deg);
   z-index:-2;
}

body {
   background-color:OrangeRed;
   font-family:Arial, sans-serif;
}
</style> 
 </head> 
 <body> 
  <div class="container"> 
   <div class="parent">
     Lorem ipsum 
    <div class="child">
      Lorem ipsum 
    </div> 
   </div> 
  </div> 
  <div class="container"> 
   <div class="fake_child">
     Lorem ipsum 
    <div class="fake_parent">
      Lorem ipsum 
    </div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials