Position of overlay to center of page - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Position

Description

Position of overlay to center of page

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">
.red {<!-- w  w w.  j av  a 2s .  c om-->
   width:100px;
   height:100px;
   background-color:Chartreuse;
   padding-left:21px;
}

.blue {
   width:51px;
   height:61px;
   background-color:yellow;
   padding-left:0;
}

.green {
   width:31px;
   height:91px;
   background-color:blue;
   padding-left:0;
}

.center {
   opacity:0.9;
   position:fixed;
   top:51%;
   left:51%;
   -ms-transform:translate(-51%,-51%);
   -webkit-transform:translate(-51%,-51%);
   transform:translate(-51%,-51%);
}
</style> 
 </head> 
 <body> 
  <div class="red center"></div> 
  <div class="blue center"></div> 
  <div class="green center"></div>  
 </body>
</html>

Related Tutorials