Centered horizontally via position absolute - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Absolute Position

Description

Centered horizontally via position absolute

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">
#header {<!-- w  ww  .jav a2 s.  co m-->
   height:100px;
   background:blue;
}

#main {
   width:501px;
   background:yellow;
   margin:0 auto;
}

#footer {
   height:100px;
   background:green;
}
</style> 
 </head> 
 <body> 
  <div id="header"> 
  </div> 
  <div id="main">
    Lorem ipsum dolor sit 
   <br> 
   <br>Lorem ipsum dolor sit amet 
   <br> 
   <br>Lorem 
  </div> 
  <div id="footer"> 
  </div>  
 </body>
</html>

Related Tutorials