two solutions below: one with pure css, the second with jQuery, allowing any kind of symbol/image to be a separator
pre: Fairly hard to formulate an
Try this:
jQuery:
$('document').ready(function() {
$('div').find('a').not(':last-child').after(' | ');
});
HTML:
<div><a href="#">tag 1</a><a href="#">tag 2</a><a href="#">tag 3</a></div>
<div><a href="#">tag 1</a><a href="#">tag 2</a><a href="#">tag 3</a></div>
<div><a href="#">tag 1</a><a href="#">tag 2</a><a href="#">tag 3</a></div>
This way, your content separator can be any HTML content.
Yes you can do this but you need to put the |
in a tag. Look at this example
HTML:
<div id="tags">
<a href="#">C++</a>
<span>|</span>
<a href="#">PHP</a>
<span>|</span>
<a href="#">ASP</a>
<span>|</span>
<a href="#">JavaScript</a>
<span>|</span>
<a href="#">jQuery</a>
<span>|</span>
<a href="#">HTML 5</a>
<span>|</span>
<a href="#">StackOverflow</a>
</div>
CSS:
#tags {
width: 170px;
}
#tags a {
white-space: nowrap;
}
JavaScript (jQuery):
var iTop;
$("#tags a").each(function() {
if (iTop < $(this).offset().top) {
$(this).prev("span").remove();
}
iTop = $(this).offset().top;
});
Here's an idea: http://jsfiddle.net/WyeSz/
(note that the jsfiddle demo uses a CSS reset, you may need a little more CSS than this to reset list styles, etc.)
Basically, you set border-left
on the list items, then position the entire list -1px to the left within a container that has overflow:hidden
, which cuts off the left borders.
<div>
<ul>
<li>C++</li>
<li>PHP</li>
<li>CSS</li>
<li>ASP</li>
<li>JavaScript</li>
<li>jQuery</li>
<li>HTML 5</li>
<li>StackOverflow</li>
</ul>
</div>
ul {
width:200px;
margin-left:-1px;/* hide the left borders */
}
li {
float:left;
padding:2px 10px;
border-left:1px solid #000;
}
div {
overflow:hidden;/* hide the left borders */
}