Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Separators for Navigation

I need to add separators between elements of navigation. Separators are images.

Separators between elements.

My HTML structure is like: ol > li > a > img.

Here I come to two possible solutions:

  1. To add more li tags for separation (boo!),
  2. Include separator in image of each element (this is better, but it makes possibility that user may click on, example, "Home", but get to "Services", because they are one behind the other and user may accidentally click on separator that belongs to "Services");

What to do?

like image 548
daGrevis Avatar asked Apr 16 '11 18:04

daGrevis


People also ask

How to add separator in navbar?

To add link dividers in a Navigation Bar, use the border-right property for the <li> element.

How do I add a separator to my WordPress menu?

Adding WordPress Menu Separator In the Custom links block add a new menu item with the same name. Add # hash symbol. Add # hash symbol into the link field to create a non-clickable menu item. Click on Add to Menu button to add the non-clickable item (separator) to your existing menu.


2 Answers

If there isn't a pressing need to use images for the separators, you could do this with pure CSS.

nav li + li:before{     content: " | ";     padding: 0 10px; } 

This puts a bar between each list item, just as the image in the original question described. But since we're using the adjacent selectors, it doesn't put the bar before the first element. And since we're using the :before pseudo selector, it doesn't put one at the end.

like image 103
jrue Avatar answered Sep 17 '22 22:09

jrue


Simply use the separator image as a background image on the li.

To get it to only appear in between list items, position the image to the left of the li, but not on the first one.

For example:

#nav li + li {     background:url('seperator.gif') no-repeat top left;     padding-left: 10px } 

This CSS adds the image to every list item that follows another list item - in other words all of them but the first.

NB. Be aware the adjacent selector (li + li) doesn't work in IE6, so you will have to just add the background image to the conventional li (with a conditional stylesheet) and perhaps apply a negative margin to one of the edges.

like image 31
ajcw Avatar answered Sep 20 '22 22:09

ajcw