tags:

views:

22

answers:

2

I am having this issue and I am hoping that it is so simple and that is why I can not figure it out.

I want to use an image divider inbetween navigation <li> elements.

Here is my CSS:

#nav {
    width:70.5%;
    padding-left:29.5%;
    list-style: none;
    margin: 0px auto;
    float:left;
    background-image:url(images/bk_nav.gif);
    background-repeat:repeat-x;
    display:block;
    text-align:center;
    #margin-top:-4px;
}


#nav li {
    float: left;
    margin: 0px;
    text-align:center;
    font: 13px/100% Helvetica, Arial, sans-serif;
    background-color:#cccccc;
}
.divide
{
    position:relative;
    float:left;
    width:4px;
    height:42px;
    background-image:url(images/divider.gif);
}
#nav a {
    color: #ffffff;
    text-decoration: none;
    text-align:center;
    padding: 14px 25px 14px 25px;
    font: 14px/100% Helvetica, Arial, sans-serif;
    display: block;
    text-align:center;
}

Here is the HTML:

<ul id="nav">
      <li class="page-item-2 current_page_item"><a href="index.html">Home</a></li><span class="divide"></span>
      <li class="page-item-20"><a href="aboutus.html">Our Program</a></li>
      <li class="page-item-10"><a href="econsus.html">Social</a></li>
      <li class="page-item-13"><a href="socialsus.html">Economic</a></li>
      <li class="page-item-15"><a href="envsus.html">Environmental </a></li>
      <li class="page-item-17"><a href="resources.html">Resources </a></li>
    </ul>

Currently I only have one divider in there because I am testing it. This code works fine in FF but IE is destroyed by it. Anyone shed some light on this frustrating situation?

UPDATE:

The one is right and the other is not. I was able to create the same error in FF so you can see both. (Just moved the <span>)

alt text

+2  A: 

First thing's first:

A span cannot be a direct child of a ul element. It is not standard HTML, and so there's no telling what might happen. Only lis can be children of uls.

Suggestion:

I would, were I you, put the divide class on an li instead. That way, you have standard HTML at the very least, and maybe it'll even fix the page. Other than that, I would need a link to a demo as Bears will eat you suggested to be of any assistance.


I'm not entirely sure what "entire background" means, but I'm going to suggest that you use background-position and background-repeat to help. Read through these and it should help you figure out what you'd like to do.

Jeff Rupert
@Jeff Rupert Can I put the small divider image on the li's without making it the entire background? Link provided above.
Bry4n
What do you mean by "entire background"?
Jeff Rupert
@Bry4n: yes; you can use `background-repeat: none;` to prevent it being repeated across the entire `li`. Coupled with `background-position` to position it appropriately.
David Thomas
@ricebowl: That's what I was thinking the OP was asking about.
Jeff Rupert
@Jeff Rupert Ah I see what you mean. Well the buttons look odd now. Additional Link provided.
Bry4n
@Bry4n: That's because you have `background-color:#cccccc;` in the CSS for `#nav li`.
Jeff Rupert
@Jeff Rupert I took that out and for some reason it still was gray haha. It's fixed now. Thanks!
Bry4n
+1  A: 
<ul>
  <li>list item</li>`
  <li class="divider"></li>
  <li>list item 2</li>
</ul>

Then, in order to make the divider appear closer to the list items, just adjust the margin/padding of the .divider class

Moses
@Moses Hail Moses! I couldn't believe I forgot that. Been awhile since I added those dividers...god I am an idiot =/
Bry4n
No problem, it's usually the simplest things that we tend to overlook.
Moses