Is there anyway to accomplish a leading ellipsis using CSS? Like in a table of contents where the title of the section is followed by ellipsis until the page number which is shown on the right of the page.
Like this:
Ellipsis to end of element.
(Outlines shown to identify different elements.)
-
Given what mark-up? As your question stands you're asking a fairly open question ('not a real question'/'too localized')David Thomas– David Thomas2012年02月24日 19:38:30 +00:00Commented Feb 24, 2012 at 19:38
-
It's okay, just wondering if it is possible...markup doesn't matter much...Josh M.– Josh M.2012年02月24日 22:23:32 +00:00Commented Feb 24, 2012 at 22:23
3 Answers 3
Here's a crude example with just floated elements/overflow: http://jsfiddle.net/8Ngv5/
It would be less crude if you could fix the widths of all elements.
Here is a more elegant example: http://jsfiddle.net/8Ngv5/2/
This one uses the :before pseudo-class to inject a long string which is then covered by the left element. The left element has to be positioned to sit atop the line, and it needs a background to cover the line (see CSS).
This works in IE9, Chrome, and Firefox.
Result
enter image description here
HTML
<div class="left">Hello</div>
<div class="right">World</div>
<br>
<div class="left">Another Line</div>
<div class="right">With Longer Content</div>
<br>
<div class="left">Another Line 2</div>
<div class="right">2 With Longer Content</div>
CSS
BODY {
line-height: 1.2em;
}
.left {
float: left;
position: relative;
top: 1.2em;
background-color: #fff;
}
.right:before {
content: "...............................................................................................................................................................................................................................................................................................................................................................................................................................";
}
.right {
float: right;
white-space: nowrap;
text-align: right;
}
4 Comments
:before and content are new to me, very interesting!You can use the :before selector and content: "...";
.some-class:before
{
content: "...";
}
Comments
you could use the :before or :after selectors?