+ Reply to Thread
Results 1 to 3 of 3

Thread: help with positioning

  1. #1
    dellerdynamics is offline x10Hosting Member dellerdynamics is an unknown quantity at this point
    Join Date
    Nov 2008
    Posts
    5

    help with positioning

    i have no idea what is wrong with this code, but the subnav starts after the search for some reason. How do i make the subnav start on its own line directly after the main navigation.

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <title>title</title>
    <style type="text/css">
    ul#nav {
        margin: 0;
        padding: 0 0 0 6px;
        width: 954px;
        height: 44px;
        background: #000 url(images/nav_bg.gif) repeat-x;
        color: inherit;
    }
    ul#nav li {
        float: left;
        margin: 0;
        padding: 15px 0 0 0;
        list-style-type: none;
        text-transform: uppercase;
        font-variant: small-caps;
        font: 10px "Trebuchet MS", Arial, Helvetica, Sans-serif;
    }
    ul#nav li a {
        text-decoration: none;
        padding: 13px 30px 14px 30px;
    }
    ul#nav li a:link, ul#nav li a:visited {
        background-color: inherit;
        color: #fff;
    }
    ul#nav li a:hover, ul#nav li a:active {
        background-color: inherit;
        color: #c9f381;
    }
    #nav input {
        background: #272727 url('images/searchbg.png') repeat-x;
        color: #999;
        border: 1px solid #444;
        font-size: 10px;
        padding: 0px;
        -moz-border-radius: 15px;
        -webkit-border-radius: 15px;
        position: relative;
        right: 6px;
        bottom: 10px;
    }
    /* SUBNAV */
    
    ul#subnav {
        margin: 0;
        padding: 0 0 0 30px;
        width: 930px;
        height: 31px;
        background: #000 url(images/subnav_bg.gif) repeat-x;
        color: inherit;
        font-size: 9px;
    }
    ul#subnav li {
        float: left;
        margin: 0;
        padding: 0 0 0 0;
        list-style-type: none;
        text-transform: uppercase;
    
    }
    ul#subnav li a {
        text-decoration: none;
        padding: 7px 20px 7px 20px;
        background: transparent url(images/subnav_sep.gif) no-repeat left;
    }
    ul#subnav li a:link, ul#subnav li a:visited {
        background-color: inherit;
        color: #fff;
    }
    ul#subnav li a:hover, ul#subnav li a:active {
        background-color: inherit;
        color: #ccc;
    }
    ul#subnav li#subnavfirst a:link, ul#subnav li#subnavfirst a:visited {
        background: transparent url(images/subnav_icon.gif) no-repeat left;
        color: #fff;
    }
    ul#subnav li#subnavfirst a:hover, ul#subnav li#subnavfirst a:active {
        background: transparent url(images/subnav_icon.gif) no-repeat left;
        color: #ccc;
    }
    </style>
    </head>
    
    <body>
    <ul id="nav">
    <li><a href="/index/" title="Home">Home</a></li>
    <li><a href="/projects/" title="Projects">Projects</a></li>
    <li><a href="/software/" title="Software">Software</a></li>
    <li><a href="/photoshop/" title="Photoshop">Photoshop</a></li>
    <li><a href="/other/" title="Other">Other</a></li>
    <li><a href="/about/" title="About">About</a></li>
    <li><a href="/i7/" title="Item 7">Item 7</a></li>
    <li><form id="googleSearchForm" method="get" action="http://www.google.com/search">
                <p>
                    <input id="googleSearchInput" value="Search" onfocus="this.value='';" onblur="this.value='Search';" type="text" />
                </p>
            </form></li>
    </ul>
    <ul id="subnav">
     <li id="subnavfirst"><a href="javascript: void;" title="Login">Login</a></li>
     <li><a href="javascript: void;" title="">Item 1</a></li>
     <li><a href="javascript: void;" title="">Item 2</a></li>
     <li><a href="javascript: void;" title="">Item 3</a></li>
    </ul>
    </body>
    </html>

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: help with positioning

    I assume you're talking about the fact that the "Login" link is on the far right of the navbar. This is because all the li are floated & there's space for the "login" link on the right. To fix this, you need to apply a "clear: left" to some element after #nav ends. If it weren't for IE6, you could use:
    Code:
    ul#subnav li:first-child {
        clear: left;
    }
    Until IE6 is dead, try:
    Code:
    ul#subnav {
        clear: left;
    }
    or
    Code:
    ul#subnav li:first-child, ul#subnav li#subnavfirst {
        clear: left;
    }
    See how each approach affects layout. I still include a "ul#subnav li:first child" selector above to prepare for when "#subnavfirst" is unneeded. "clear:both" will also probably work.

    One other suggestion: use class attribute rather than id when you want to mark a node to be picked up by a CSS selector based on a property it might share with other nodes, such as being a first child. The advantages can be subtle but useful.
    Code:
    ul#subnav li:first-child, ul#subnav li.firstChild {
        clear: left;
    }
    ...
    <li class="firstChild"><a href="javascript: void;" title="Login">Login</a></li>

    BTW, good job with the test case; not too much extraneous markup to wade through.

  3. #3
    vol7ron's Avatar
    vol7ron is offline x10 Lieutenant vol7ron is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    DC
    Posts
    434

    Re: help with positioning

    You should be fine with just subnav

    ul#subnav { clear: left; }


    also, take away the paragraph tags (<p>) around the <form> element.
    after you do that, change the input box's positioning: #nav input {bottom: 10px;} to 0px;
    Last edited by vol7ron; 12-15-2008 at 11:04 AM.
    If you find my post useful please add to my reputation by clicking the +Rep button
    You may also use the Donate link to donate credits - this is appreciated too Thanks to those whom have donated so far!


+ Reply to Thread

Similar Threads

  1. CSS Positioning Help
    By Ainokea in forum Programming Help
    Replies: 10
    Last Post: 11-06-2008, 05:05 AM
  2. CSS positioning woes.
    By Farenvin in forum Programming Help
    Replies: 9
    Last Post: 04-19-2008, 09:16 PM
  3. positioning ads in Coppermine
    By dylan in forum Free Hosting
    Replies: 6
    Last Post: 11-03-2005, 12:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers