Positioning <div> element at center of screen - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Position

Description

Positioning <div> element at center of screen

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">
.popup {<!--   w w w . ja  va 2  s.  c o  m-->
   position:fixed;
   top:51%;
   left:51%;
   -webkit-transform:translate(-51%, -51%);
   transform:translate(-51%, -51%);
   border:2px solid Chartreuse;
}
</style> 
 </head> 
 <body> 
  <div class="popup">
    Lorem ipsum dolor sit amet, 
   <br> 
   <img src="https://www.java2s.com/style/demo/Opera.png"> 
  </div>  
 </body>
</html>

Related Tutorials