I need to trim a dynamic text in order to make a 2 lines excerpt out of it (a teaser). The problem is that the number of lines that takes a displayed string within a div depends on the characters used (for instance,"w" and i" will not have the same width), the browser and the OS (a font on Mac is not exactly equal to the same font on Windows).
Is there a way, in javascript, to trim a text that would be longer than x lines within a div (knowing that the div length is fixed)?
Thank you.
measureText(); keep adding words until you surpass the width of your container, and do that again for a second line.