I need to add separators between elements of navigation. Separators are images.
My HTML structure is like: ol > li > a > img
.
Here I come to two possible solutions:
li
tags for separation (boo!),What to do?
To add link dividers in a Navigation Bar, use the border-right property for the <li> element.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With