CSS Ellipsis Beginning of StringI was incredibly happy when CSS
text-overflow: ellipsis (married with fixed
text-overflow: ellipsis feature is great but is essentially meant to ellipsize strings only at the end; what if we want to ellipsize the beginning of a screen? The use case is fairly reasonable: think displaying a file path -- many times the directory for a set of files is the same, in which case you'd want to display the end of the string, not the beginning.
Let me show you a trick for ellipsis at the begging of the string!
Showing an ellipsis at the front of a string is mostly the same as ellipsis at the end, only with one simple trick:
/* Standard CSS ellipsis */
/* Beginning of string */
To add an ellipsis at the beginning of a string, use RTL and and
text-align to clip the beginning of the string!
Playing RTL off of
text-align is a genius way to get the desired effect of CSS ellipsis at the beginning of an element or string. It would be great for the CSS spec to implement a more robust ellipsis system but, for now, I worship amazing CSS tricks like this!
Your early CSS books were instrumental in pushing my love for front end technologies. What was it about CSS that you fell in love with and drove you to write about it?
At first blush, it was the simplicity of it as compared to the table-and-spacer...
The way that album information displays is usually insanely boring. Music is supposed to be fun and moving, right? Luckily MooTools and jQuery allow us to communicate that creativity on the web.
A few structure DIVs and the album information.
The CSS spec seems to recommend against using the
directionproperty on web pages:
Happy to have helped!
This seems kind of strange. Where is the extra slash coming from?
This trick seems to be broken for Safari which still truncates from the back then appends the ellipsis to the front.
Chrome/FF: 12345 => …345
Safari: 12345 => …123
For anyone having issues with symbols, like the plus sign in international phone numbers, add this:
If anyone dealing with multiline strings to truncate i recommend using the cuttr.js (https://github.com/d-e-v-s-k/cuttr-js) library ;)