Centered fixed-width layout with elements extending over the whole page - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Layout

Description

Centered fixed-width layout with elements extending over the whole 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">
#main_container<!--from  www .  j ava 2s .  c  o  m-->
 {
   width:401px;
   min-height:361px;
   margin:11px auto;
   background:Chartreuse;
   overflow:visible;
}

#heading_div_bg
 {
   background-color:yellow;
   height:51px;
   width:100%;
   position:absolute;
   margin:0px auto;
   left:0px;
   top:51px;
}

#heading_div
 {
   background-color:blue;
   text-align:center;
   height:51px;
   width:401px;
   position:relative;
   margin:0 auto;
}
</style> 
 </head> 
 <body> 
  <div id="main_container"> 
   <div id="heading_div_bg"> 
    <div id="heading_div"> 
     <h2>Lorem ipsum do</h2> 
    </div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials