www.webdeveloper.com
Results 1 to 2 of 2

Thread: Horizontal Streching

  1. #1
    Join Date
    Oct 2006
    Posts
    1

    Horizontal Streching

    Hi,

    I am trying to build a site without using tables. I have 7 links in the navigation bar, and would like these 7 links to be evenly spaced and fill the whole navigation bar (horizontally). Is there any way to achieve this using CSS. This is my html:

    HTML Code:
    <html xmlns="http://www.w3.org/1999/xhtml">
    
            <head>
                    <title>CSS test page</title>
                    <link rel="stylesheet" type="text/css" href="style.css"/>
            </head>
    
            <body>
                    <div id="container">
                            <div id="menu">
                                    <ul>
                                            <li><a href="">link1</a></li>
                                            <li><a href="">link2</a></li>
                                            <li><a href="">link3</a></li>
                                            <li><a href="">link4</a></li>
                                            <li><a href="">link5</a></li>
                                            <li><a href="">link6</a></li>
                                            <li><a href="">link7</a></li>
                                    </ul>
                            </div>
                    </div>
            </body>
    
    </html>
    and this is my stylesheet:

    Code:
    body
    {
            font-family: Verdana, Arial, Sans-Serif;
            font-size: 10px;
    }
    
    #container
    {
            width: 750px;
            margin: 0 auto;
            position: relative;
    }
    
    #menu
    {
            border: thin solid black;
    }
    
    #menu ul
    {
            margin: 0;
            text-align: center;
            list-style-type: none;
    }
    
    #menu li
    {
            display: inline;
    }

    Thanks!
    is-serp
    Last edited by is-serp; 10-03-2006 at 01:30 PM.

  2. #2
    Join Date
    Jan 2005
    Location
    Frankfort, KY, USA
    Posts
    6,167
    You can select a width for each list item's link, based on a percentage: 14%. That way, they will be evenly spaced, no matter the screen resolution.
    Code:
    li a {display: block; width: 14%;}
    KDLA
    Last edited by KDLA; 10-03-2006 at 01:45 PM. Reason: forgot coding
    FYI
    * My screen resolution is set at 1680x1050
    * I'm accessing your site through a T1 line
    * I'm probably viewing it using Firefox (unless browser is specified)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles