Results 1 to 7 of 7

Thread: vertical list navigation problems

  1. #1
    Join Date
    Dec 2007
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default vertical list navigation problems

    Hi all,

    I'm having trouble creating a vertical list navigation with images as backgrounds.

    the CSS:

    <style type="text/css">

    #secondary_nav {
    float: left;
    clear: both;
    width: 200px;
    height: 360px;
    background-color:gray;

    }

    #nav li {
    list-style: none;
    float:left;
    clear: left;
    }

    #nav li a {
    display: block;
    text-indent: -5000px;
    height: 20px;
    width: 200px;
    }

    #nav li a#about_us {
    background: url(../images/buttons/about_us.jpg) no-repeat;
    }
    #nav li a#about_us:hover{
    background: url(../images/buttons/about_us_over.jpg) no-repeat;
    }
    #nav li a#process{
    background: url(../images/buttons/process.jpg) no-repeat;
    }
    #nav li a#process:hover{
    background: url(../images/buttons/process_over.jpg) no-repeat;
    }

    </style>



    <!-- the HTML -->

    <body>

    <div id="secondary_nav">
    <ul id="nav">
    <li><a href="#" id="about_us">Home</a></li>
    <li><a href="#" id="process">Archive</a></li>
    </ul>
    </div>


    </body>
    </html>


    <!-- the problem -->
    The list boxes look as though they have margin-left and margin-top to them. They are moved to the right and down?? I'm sure it has something to do with "display: block;" but if I remove that it messes up the menu.

    The look in Safari and Dreamweaver

  2. #2
    Join Date
    Dec 2004
    Posts
    177
    Thanks
    0
    Thanked 18 Times in 17 Posts

    Default

    It's because of <ul>and <li>.

    Those tags are for unordered lists, which automatically layout items like:

    ul
    ---li
    ---li
    Verzeihung!

  3. #3
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Quote Originally Posted by Minos View Post
    It's because of <ul>and <li>.

    Those tags are for unordered lists, which automatically layout items like:

    ul
    ---li
    ---li
    Right...but there is a solution. You're not tied into that format.


    @stevedc
    You'll need to remove that padding/margin from the unordered list. To do so add the following CSS:

    Code:
    #secondary_nav {
    float: left;
    clear: both;
    width: 200px;
    height: 360px;
    background-color:gray;
    margin:0;
    padding:0;
    list-style:none;
    }
    If you were using that float to try to fix this issue, you won't need it.

  4. #4
    Join Date
    Dec 2007
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Minos and Medyman, thanks for the quick reply! However, Minos, I just added the CSS exactly as you have it and still no fix : (. I also tried removing the float property, adding 0 margin and padding to other areas of the CSS list and still nothing.

  5. #5
    Join Date
    Dec 2004
    Posts
    177
    Thanks
    0
    Thanked 18 Times in 17 Posts

    Default

    Quote Originally Posted by Medyman View Post
    Right...but there is a solution. You're not tied into that format.
    I never said he was tied to it :P. And while removing the padding from the list is a solution, I don't quite see the point (in this case). It's the same effect as <b></b> a word and then using css to remove the bold.

    Why not just replace them with divs?

    Code:
    <div id="nav">
    <div><a href="#" id="about_us">Home</a></div>
    <div><a href="#" id="process">Archive</a></div>
    </div>
    If there is another motive for using and altering the unordered list, by all means, I'll help work around it.
    Verzeihung!

  6. #6
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Quote Originally Posted by Minos View Post
    Why not just replace them with divs?

    Code:
    <div id="nav">
    <div><a href="#" id="about_us">Home</a></div>
    <div><a href="#" id="process">Archive</a></div>
    </div>
    .
    putting them within divs is not using correct coding... navigational menus are best defined as unordered lists, then using CSS styles to remove the bullets, and apply the appropriate background margins/padding to fit with the background image wanted.

    I never said he was tied to it :P. And while removing the padding from the list is a solution, I don't quite see the point (in this case). It's the same effect as <b></b> a word and then using css to remove the bold.
    Navigation / Menus are lists (ul/ol), not blocks of code (div)

    On a side note... <b></b> tags should be used only for a "presentational" bolding effect. If you actually want that word/phrase to be emphasized or pronounced, the correct code is <strong></strong>

    same goes for <i></i> and <em></em>

    Medyman was about 80% correct in his styling.
    You need to 2 different styles here to do this correctly.
    You need to first apply a styling to the <ul> to rid the list of bullets, and you could use the float property if you are coding the menu to be as its own column .... eg... dont waste an extra <div> to declare a left/right column.

    you would then need to apply a style to the list items ( <li> ) to get rid of the default margin/padding then apply margins/padding for a background image (ps they should all be the same size)

    Code:
    ul#nav {
         float:left;
         list-style-type: none;
    }
    ul#nav li {
         margins: 0;
         padding: 5px 0 5px 20px; /* 5top 0right 5bottom 20left */ 
    }
    ul#nav li a#about_us {
         background: transparent url('/images/buttons/about_us.jpg') no-repeat top left;
    }
    ul#nav li a#about_us:hover {
         background: transparent url('/images/buttons/about_us_over.jpg') no-repeat top left;
    }
    ul#nav li a#process {
         background: transparent url('/images/buttons/process.jpg') no-repeat top left;
    }
    ul#nav li a#process:hover {
         background: transparent url('/images/buttons/process_over.jpg') no-repeat top left;
    }

  7. #7
    Join Date
    Dec 2007
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Boogyman,

    Excellent! I have it working the way I want now. Thank you all for helping me think this one through.

    ~ Regards
    Steve Case

Bookmarks

Posting Permissions

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