Center a box in the vertical and horizontal middle of the screen and place other boxed underneath - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Box

Description

Center a box in the vertical and horizontal middle of the screen and place other boxed underneath

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">
.wrapper {<!--from ww  w .ja  v  a  2s . com-->
   position:fixed;
   top:51%;
   left:51%;
   transform:translate(-51%, -51%);
}

#centeredBox {
   position:relative;
   border:2px solid Chartreuse;
}

#underCenteredBox {
   display:block;
   background-color:yellow;
   position:relative;
}

#underUnderCenteredBox {
   display:block;
   background-color:blue;
   position:relative;
}
</style> 
 </head> 
 <body> 
  <div class="wrapper"> 
   <div id="centeredBox">
     Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper mol 
   </div> 
   <div id="underCenteredBox">
     Lorem ipsum dolor 
   </div> 
   <div id="underUnderCenteredBox">
     Lorem ipsum dolor sit a 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials