I need to implement ellipsis (\"...\") in the middle of a text within a resizable element. Here is what it might look like. So,
\"Lorem ipsum do
So my colleague came up with a solution that uses no extra dom elements. We check to see if the div overflows and add a data attribute of the last n characters. The rest is done in css.
Here is some HTML:
This is my text it is awesome
This is my text
And the css:
.box {
width: 200px;
}
.ellipsis:before {
float: right;
content: attr(data-tail);
}
.ellipsis {
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
Here is the obligatory jsfiddle for this: http://jsfiddle.net/r96vB/1/