views:

266

answers:

1

I am trying to put together a page that has a header that spans accross the page.

the header contains menu items and looks something like this (ASCII rendering below)

<------ Fixed Width ----------> <----------- Variable Width (Depends on Screen Width) -->

-----------------------------------------------------------------------------------------
  LOGO HERE (Fixed Width)     |    Menu One  |  Menu Two | menu Three | Menu Four      
                              |              |           |            |                
-----------------------------------------------------------------------------------------

I have designed this in HTML like this:

<div id="topMenu">
    <div id="topMenuLogo"><!-- flash logo stuff here --></div>
    <div id="topMenuContainer">
       <div id="topMenuTopBar" class="right-align">
           <div class="useroption floatleft">Action 1</div>
           <div class="useroption floatleft">Action 2</div>
           <div class="spacer">&nbsp;</div>
       </div>
       <div id ="topMenuNavBar">
           <div id=topmenuMenuContainer">
              <ul>
                 <li>Menu One</li>
                 <li><!-- Other menus follow below ...... --></li>
              </ul>
           </div>
        </div>
       <div class="spacer">&nbsp;</div>
    </div>
    <div class="spacer">&nbsp;</div>        
</div>

where the CSS class 'spacer' matches the pattern {height:1px;clear:both;}

I want to be able to write the above so that the page dynamically expands to fit the screen regardless of the resolution. The logo has a fixed width so that does not change, but I want the topMenuContainer dive element to adjust its width dynamically depending on the screensize. basically, that element will contain the following:

  1. A topMenuContainer element that expands or contracts depends on the screen resolution
  2. A topMenuTopBar that is floated right within the topMenuContainer element

  3. A topMenuNavBar that is floated left within the topMenuContainer element

I would be very grateful if someone could show the CSS required to structure the above HTML snippet in the manner I have described.

+1  A: 

This should be your #1 resource for general layout questions like these:

http://layouts.ironmyers.com/

You will find any CSS layout you could possibly want on his site. If you don't know CSS yet, you can check out the tutorials at w3schools:

http://www.w3schools.com/css/

Goose Bumper
Useful link, but it still dosent answer my question - which is how to create an element (container) with a fixed width and variable width part.
Stick it to THE MAN
To clarify further, I can already create such pages - as they are quite straightforward. What I am trying to do is more complicated than any of the examples on that site (AFAICT). If I way to take one of the examples on the site, I will still have the problem of fitting my masthead or header section into the page, so the problem remains unsolved.
Stick it to THE MAN
If I understand your question, you want a container that resizes with the page, but has a minimum width, correct? I.e. the container can expand to any width, but has to be at least as wide as your mast head? In that case you would just use the min-width css property to specify a minimum width.
Goose Bumper
I must be doing sopmething wrong, because that is exactly what I did (using the min-width property. I will have to check my pages again - thanks for coming that though ...
Stick it to THE MAN
No problem! I'll take my accepted answer with cream, thank you :)
Goose Bumper
Sorry, about delay. I accepted your answer now. with lots of added cream :D
Stick it to THE MAN