position a div to be visible but not count towards document width - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Position

Description

position a div to be visible but not count towards document width

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">
html, body {
   margin:0;
   padding:0;
   height:100%;
   border:none;
}

#container {<!--   ww w  .  ja va 2  s .  c o  m-->
   position:relative;
   width:971px;
   margin:0 auto;
   height:auto !important;
   height:100%;
   min-height:100%;
   background:red;
}

#header {
   height:202px;
   margin:0 auto;
   padding:0;
   position:relative;
   z-index:3;
   width:971px;
}

#headerBackground {
   background:url('https://www.java2s.com/style/demo/Google-Chrome.png') no-repeat top left Chartreuse;
   height:202px;
   position:relative;
   z-index:2;
}

.holder {
   position:absolute;
   top:0;
   width:100%;
}

#top {
   position:absolute;
   height:171px;
   background:yellow;
   left:0;
   top:0;
   width:100%;
}
</style> 
 </head> 
 <body> 
  <div id="top"></div> 
  <div class="holder"> 
   <div id="headerBackground"></div> 
  </div> 
  <div class="holder"> 
   <div id="header"></div> 
  </div> 
  <div id="container"> 
   <div id="content"></div> 
   <div id="footer"></div> 
  </div>  
 </body>
</html>

Related Tutorials