Position an overlay in the center of the page - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Position

Description

Position an overlay in the center of the 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">
.mydiv {<!-- ww  w .  jav a2 s .c om-->
   width:301px;
   height:301px;
   background:red;
   position:fixed;
   top:51%;
   left:51%;
   margin-top:-151px;
   margin-left:-151px;
}
</style> 
 </head> 
 <body> 
  <div class="mydiv"></div>  
 </body>
</html>

Related Tutorials