tags:

views:

23

answers:

2

Hello,
Got a newbie CSS question, just beginning to get into CSS so please bear with me.
In my ASP.NET MVC app there's a menu:

<div id="menucontainer">
            <ul id="menu">
                <li>something</li>
                <li>something</li>
                <li>something</li>
                <li>something</li>
                <li>something</li>
            </ul>
        </div>

And CSS styles for it:

ul#menu
{
    border-bottom: 1px #5C87B2 solid;
    padding: 0 0 2px;
    position: relative;
    display: inline;
    margin: 0;
    width: 100%;
    text-align: left;
    list-style: none;
}

ul#menu li
{
    display: inline;
    position: relative;
    list-style: none;
}

#menucontainer
{
    margin-top: 40px;
    width: 100%;
}

How can I make some of the li elements align left and the rest of them right in a single line? Tried to break it into two menus and write two different styles, just can't seem to get the right css. Probably have to build a valid box model - any pointers on that?

A: 

You'll need two <ul>s, one with float:left and the other with float:right. That should do it.

Skilldrick
ul#menu{ border-bottom: 1px #5C87B2 solid; padding: 0 0 2px; position: relative; display: inline; margin: 0; width: 100%; text-align: left; list-style: none; float: left;}ul#menu-right{ border-bottom: 1px #5C87B2 solid; padding: 0 0 2px; position: relative; display: inline; margin: 0; width: 100%; text-align: left; list-style: none; float: right;} This breaks my menu into two lines.
pklosinski
Take off the `width: 100%` then - that's making each `<ul>` take up the whole width.
Skilldrick
It does kinda work now, only the menu now overlaps a main content div, which was below the menu before. What could cause that?
pklosinski
Managed. Added "<br style="clear: both;" />" after the menu div. Thanks for your help!
pklosinski
@pklonsinski: Yes, floats can cause all manner of layout issues with the following content. The best solution I know of is is this clearfix: http://www.pathf.com/blogs/2007/09/developers-note-2/
Skilldrick
A: 

There are several methods on how to do what you want. A List Apart has an article about 6 different methods on how to do this.

Ramon Marco Navarro