I’m currently using the css property ellipsis to add an ellipsis to the end of my line. However, I also want to display the number of words after the ellipsis. For instance
.names {
border: 1px solid #000000;
white-space: nowrap;
width: X;
overflow: hidden;
text-overflow: ellipsis;
}
<div class="names">Tim, Tom, Mary, Bob, Sam, John</div>
Shows
Tim, Tom, Mary, …
But, in this case I would want to show that the ellipsis represents 3 other names.
Tim, Tom, Mary, … and 3 others
What’s the minimal way to do this, either in javascript or with css. I’m using a webview in an iOS app and this will have to get calculated on every row item in a table so I would need to have a very lightweight js function.
I probably need a lot more rigid requirements in order to give you a better / more robust code for this. But I assume something like this is what you were looking for.
http://jsfiddle.net/Xf47e/3/
I don’t know how you are currently dealing with your code issues but I’d be surprised if you haven’t faced the issue of H… aka a half cut word already as well as many other problems that arise with the fact that character widths are most likely not constant with whatever font you are using.