I’ve yet to see a known-good way of using a different image between different nav menu elements, though I know there is a way to use one image as the consistent separator.
I have seven nav elements:
#menu-item-26{
}
//blue square here
#menu-item-25{
}
//yellow square here
#menu-item-24{
}
//red square here
#menu-item-23{
}
//pink square here
#menu-item-22{
}
//green square here
#menu-item-21{
}
//purple square here
#menu-item-20{
}
And I’ve created 6 images in photoshop, essentially just 10px by 10px squares, each a different color. I want to use a different one between each set but I don’t know if it would need to be used as a background image with each item and padding or if maybe there’s another responsive-friendly way.
2
Answers
You have a lot of options available to you. You can use an element to place the image, I would start with
<img>
unless you have a good reason not to. Though you can use it as a background image too. Simply usebackground-position
to place it on the element and provided a little extra padding for the background image to reside in.Here’s a couple options.
Using an Element
<img>
Using as Background Image
— Edit —
After seeing an answer to a comment above. Since your images are actually a solid color you can use elements with a background color to reduce network requests and simplify maintenance and flexibility of application.
Using Elements Instead of Images
You could also use a pseudo element instead of an actual element like above.
Using Pseudo Elements Instead of Images
Maybe something like this, using
:before
selector and thecontent:"";
style.