tags:

views:

52

answers:

2

Hi I have a container which has a width of 1150px. Now I have this other mainmenu, with width: 100% that I want to place inside the container. But then ofcourse it only get 100%(1150px) but I want it full width from side to side, so it should ignore the setted width only for .mainmenu

I tried position: absolute which made it all wrong and weird

#mainmenu
{
    height: 37px;
    width: 100%;
    margin: 0px auto;
    background-image: url(../images/mainmenu_bg5.jpg);

}
A: 

If your container is fixed-width, but you want a menu which has a background at full page-width, then you can have the menu background as a positioned background of html, and maintain the same HTML code. This will make the menu's background "bar" cover the whole page width.

Example of this method: http://templates.arcsin.se/demo/freshmade-software-website-template/index.html

How to do this: use positioned backgrounds:

http://www.w3schools.com/css/pr_background-position.asp

Delan Azabani
Yes thats what i am looking for, making a menubar like that, how can i have the menu background as positioned of html ? Can you show me an example, please check my updated question for css
Karem
A: 

Why is the menu in the container in the first place? If you want the menu to span the full width yet the contents of the container are only 1150px I think it is by definition not right to put the menu in the container. Consider restructuring your document. This is an example, I do not have your full code:

<body>
 <div id="page">
  <div id="header" style="background:Blue;">
   header header header
  </div>
  <div id="mainmenu" style="background:Green;">
   menu menu menu menu
  </div>
  <div id="container" style="width:1150px;margin:auto;background:Red;">
   container container container
  </div>
 </div>
</body>

And if you want the contents of the header and menu to span no farther than 1150px which I think is what you want then consider this:

<head>
<style type="text/css">
.pagewidth {
  width: 1150px;
  margin: auto;
}
</style>
</head>
<body>
 <div id="page">
  <div id="header" style="background:Blue;">
   <div class="pagewidth">
    header header header
   </div>
  </div>
  <div id="mainmenu" style="background:Green;">
    <div class="pagewidth">
      menu menu menu menu
    </div>
  </div>
  <div id="container" class="pagewidth" style="background:Red;">
   container container container
  </div>
 </div>
</body>
Bazzz
While your solution might be "right" (in that it works) and might also be "correct" (in that there may be an error in the original document's semantics), I think it's wrongheaded to begin with to suggest that style decisions should dictate that something is wrong with a document's data design. There is almost always a better solution to conflicting styles and correct data than to alter the data.
eyelidlessness
Agree, perhaps my wording is not perfect (I'm not a native English speaker). I used the word "consider" to indicate reflecting on the possibility to justify a change in the document. If for any reason the change in the document is not justifiable then my answer might not be the best. however if a change is justifiable, for example when the site is not published yet, then my answer might be a good solution as it is easy to implement and to understand. I think it's better than fiddling around with contradicting css rules. It depends on the situation that Karem is in, imho.
Bazzz