Make 100% width div on position absolute element - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Absolute Position

Description

Make 100% width div on position absolute element

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 {
   width:3001px;
   position:relative;
}

.normal {<!--   w w  w . j a v a  2  s.  co  m-->
   position:static;
   background:blue;
   width:100%;
   height:100px;
}

.positioned {
   position:absolute;
   background:yellow;
   width:100%;
   top:100px;
   height:100px;
}

.positioned-fix {
   position:absolute;
   background:yellow;
   width:inherit;
   top:201px;
   height:100px;
}
</style> 
 </head> 
 <body> 
  <div class="normal">
    static 
  </div> 
  <div class="positioned">
    absolute 
  </div> 
  <div class="positioned-fix">
    absolute (fix) 
  </div>  
 </body>
</html>

Related Tutorials