tags:

views:

53

answers:

3

hello. I have this menu:

#navbar {
    text-align: center;
    margin: auto;
    padding: 0;
    height: 1em; 
    }
#navbar li {

    list-style: none;
    float:left; }
#navbar li a:hover{
background-color: #CCC;
}
#navbar li a {
border: 1px solid #000;
    display: block;
    margin-right: 18px;
    margin-left: 18px;
    padding: 3px 8px;
    background-color: #FFF;
    color: #000;
    text-decoration: none; }
    #navbar li ul {
    display: none;
    width: 10em; /* Width to help Opera out */
}
    #navbar li:hover ul {
    display: block;
    position: absolute;
    margin: 0;
    padding: 0; }
#navbar li:hover li {
    float: none; }
#navbar li:hover li a {
    background-color: #FFF;
    border-bottom: 1px solid #000;
    color: #000; }
#navbar li li a:hover {
    background-color: #CCC; }


<ul id="navbar">
<li><a href="index.php">Start</a></li>
<li><a href="index.php">Vad?</a></li>
<li><a href="index.php">Kom igång!</a></li>
    <li><a href="#">Läringsartikler</a><ul>
        <li><a href="#">Subitem One</a></li>
        <li><a href="#">Second Subitem</a></li>
        <li><a href="#">Numero Tres</a></li></ul>
    </li>
    <li><a href="#">Läringsfilmer</a><ul>
        <li><a href="#">Subitem One</a></li>
        <li><a href="#">Second Subitem</a></li>
        <li><a href="#">Numero Tres</a></li></ul>
    </li>
</ul>

as you can see in navbar { i tried to use text-align: center or margin:auto but it still wont center the whole menu.. why? when i change the navbar li to float center instead of float left then it make the whole menu stupid big

A: 

You need to specify a width on your navbar ul.

#navbar {
    text-align: center;
    margin: auto;
    padding: 0;
    height: 1em; 
    width: 400px;
}
Joel Potter
A: 

There is NO center value for 'float' style attribute

-- Oops dint see that comment

Kasturi
A: 

As mentioned, there is no Float:center. In order to center using margin-left and margin-right auto, you either need to set a width (as mentioned above) or change it to display:block.

If you don't want to set a width or can't, there's a CSS hack called Shrink Wrapping that is easy to setup.

adamwstl