suppress the position: relative when using translate - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Relative Position

Description

suppress the position: relative when using translate

Demo Code

ResultView the demo in separate window

<html lang="en">
 <head> 
  <style>
#one {<!--from  ww w .j  a va  2s .co  m-->
   background-color:Chartreuse;
   width:100px;
   height:100px;
   position:relative;
}

#two {
   background-color:yellow;
   width:51px;
   height:51px;
   -webkit-transform:translateY(26px) translateX(26px);
   transform:translateY(26px) translateX(26px);
}

.displacement {
   -webkit-transform:translateY(-26px) translateX(-26px);
   transform:translateY(-26px) translateX(-26px);
   position:absolute;
   top:0;
   right:0;
   bottom:0;
   left:0;
   width:201%;
   height:201%;
}

#three {
   background-color:blue;
   height:26px;
   width:26px;
   position:absolute;
   top:0;
   left:0;
}
</style> 
 </head> 
 <body translate="no"> 
  <div id="one"> 
   <div id="two"> 
    <div class="displacement"> 
     <div id="three"></div> 
    </div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials