Need help with <ul> and <li>

Discussion in 'CSS' started by Whitey, Dec 30, 2008.

  1. #1
    Hey guys.

    In my navigation menu, I need the <a> links to display as a block and be aligned horizontally so the links go across the page. This is my markup so far:

    #menu {
        padding:0;
        margin:0;
    }
    
    #menu li {
        display: inline;
        list-style-type: none;
    }
    
    #menu a, #menu a:visited {
        display: block;
        width: 100px;
        height: 30px;
        font-family: Verdana, Geneva, sans-serif;
        letter-spacing: -1px;
        color: #CCC;
        font-size: 14px;
        text-decoration: none;
        text-align: center;
    }
    
    #menu a:active {
        background-image: url(images/active.gif);
    }
    Code (markup):
    And the HTML:

    <div id="container">
        <div id="navsbar">   
            <ul id="menu">
                <li><a href="#nogo">Home</a></li>
                <li><a href="#nogo">Features</a></li>
                <li><a href="#nogo">Login</a></li>
                <li><a href="#nogo">Support</a></li>
            </ul>
        </div>
    </div>
    Code (markup):
    I just need the list to have the "display: inline;" attribute while still having the block (as I can't see any other way of doing what I need to do).

    Cheers.
     
    Whitey, Dec 30, 2008 IP
  2. Sensei.Design

    Sensei.Design Prominent Member

    Messages:
    3,847
    Likes Received:
    162
    Best Answers:
    0
    Trophy Points:
    310
    Digital Goods:
    1
    #2
    a way to do what? did you try to use float:left; for the li's ? this Is what I do and it works pretty good
     
    Sensei.Design, Dec 30, 2008 IP
  3. Shadab

    Shadab Peon

    Messages:
    376
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Use the display: inline-block

    but as all old browsers don't support it,
    you may try using a combination of display: inline and float: left for better compatibility.
     
    Shadab, Dec 30, 2008 IP
  4. Tejbusiness

    Tejbusiness Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    hi please check below code

    CSS Code:

    #menu {
    padding:0;
    margin:0;
    float: left;
    }

    #menu li {
    display: inline;
    list-style-type: none;
    float: left;
    }

    #menu a, #menu a:visited {
    display: block;
    width: 100px;
    height: 30px;
    font-family: Verdana, Geneva, sans-serif;
    letter-spacing: -1px;
    color: #CCC;
    font-size: 14px;
    text-decoration: none;
    text-align: center;
    }

    #menu a:active {
    background-image: url(images/active.gif);
    }


    HTML Code

    <div id="container">
    <div id="navsbar">
    <ul id="menu">
    <li><a href="#nogo">Home</a></li>
    <li><a href="#nogo">Features</a></li>
    <li><a href="#nogo">Login</a></li>
    <li><a href="#nogo">Support</a></li>
    </ul>
    </div>
    </div>
     
    Tejbusiness, Dec 30, 2008 IP
  5. Whitey

    Whitey Active Member

    Messages:
    1,386
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    80
    #5
    Yeah, figured it out about 20 minutes after I posted, it works using float: left; :D

    Cheers.
     
    Whitey, Dec 30, 2008 IP