Reputation: 6197
The first part of problem is easy:
ul li
{
display: inline-block;
}
<ul>
<li>menu1</li>
<li>menu2</li>
<li>menu3</li>
</ul>
so far it works OK, but I want something between the items. For example, I want them to look alike:
menu1 | menu2 | menu3
instead of
menu1 menu2 menu3
how to do this?
Upvotes: 1
Views: 51
Reputation: 185
You can simply do that by adding a vertical line char before 'li' other than first one.
<ul>
<li>menu1</li>
| <li>menu2</li>
| <li>menu3</li>
</ul>
Upvotes: 0
Reputation: 157334
You can use :after
pseudo for this, here am using |
pipe character, which am embedding using content
property with an :after
pseudo. And for the last element, am using last-of-type
to get rid of the pipe. Here you can also add a background-image
by making the :after
pseudo an inline-block
element. You can also space upDemo the element by turning it into an inline-block
ul li:after {
content: " | ";
}
ul li:last-of-type:after {
content: "";
}
Upvotes: 2