English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I just set my horizontal menu bar to 840px width. Now I want to center the whole menu. What is the syntax and where do I place it?

2007-08-31 02:50:13 · 3 answers · asked by Kevin C 1 in Computers & Internet Programming & Design

3 answers

well, I think you have something like a

set to 840px width.
If not, I give all the style and div code.
Place this between & :

Then, do the following, where you want your main menu


Now it's centered!!

2007-08-31 03:23:30 · answer #1 · answered by shadow 5 · 1 0

You dont even need a div container to hold the menu bar in place. Use an unordered list.



Then in the stylesheet (which you should use externally, not internally. Separate your content from your presentation.)

#navigation {
width: 840px;
margin: 0 auto; /***** CENTERS THE MENU *****/
padding: 0 0 20px 10px;
}

#navigation li {
display: inline;
list-style: none;
}

#navigation li a {
float: left;
line-height: 14px;
font-weight: bold;
margin: 0 10px 5px 10px;
text-decoration: none;
}

#navigation li a.active,
#navigation a:hover {
border-bottom: 3px solid #f00;
padding-bottom: 2px;
color: #000;
}

That will give you something that looks like this:

http://www.toddlibby.net/examples/index8.html

If you want to add something to make it stick when you're on a certain page, just add:

Code:

  • Blue


  • That will give you something like this:

    http://www.toddlibby.net/examples/index9.html

    2007-08-31 05:06:01 · answer #2 · answered by Dirty Randy 6 · 0 0

    840px seems rather large for a menu bar, but... place it in a div, inside a "wrapper" div for the overall body of your page, and for the menu bar use "margin-left: auto; margin-right: auto;"
    That is,



    ...rest of your page...


    and your css:
    #menubar { margin-left: auto; margin-right: auto }

    2007-08-31 04:17:28 · answer #3 · answered by fjpoblam 7 · 0 0

    fedest.com, questions and answers