views:

26

answers:

2

For example, if you look at Facebook, they have a short blue bar on top that extends the entire width of the browser. I thought about using width:100%; but I know that it needs to have a parent element to be able to do that.

+2  A: 

One way:

<div style="position:absolute;left:0px;right:0px;height:20px">&nbsp;</div>
Robusto
+1  A: 

The document itself acts as a parent element. Divs, by default, are 100% of their parent's width.

What you probably need to do is set no margin or padding on the body element.

<html> 
  <style>
    body { margin: 0; padding: 0; }
    #strip { background: #89f; padding: 5px; }
  </style>
  <body>
    <div id="strip">This is a nav strip</div>
  </body>
</html>

Demo at http://www.coffeepowered.net/projects/navstrip.html

If you use a CSS reset, then this should Just Work.

Chris Heald