positioning a div based upon percentages with CSS - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Position

Description

positioning a div based upon percentages with CSS

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">
#block {<!--from   w  ww.  j  av a2s . co  m-->
   background-color:Chartreuse;
   height:100px;
   width:100px;
   position:absolute;
   left:51%;
   top:51%;
   transform:translate(51%, 51%);
}
</style> 
 </head> 
 <body> 
  <div id="block"></div>  
 </body>
</html>

Related Tutorials