I have a div with some standard width/height..
What css parametrs should i know, to calculate how many letters the div fit with no overflow?
I think that the following parametrs are neccessery..
- font-size
- text-indext
- letter-spacing
- line-height
Then how can i calculate the max number of letters the div fit?
First let’s assume you have a fixed css on the divs:
I would write some javascript to fill this div many times with different text (maybe pulled form actual articles) and do this in different browsers. Each time calculate the maximum number of characters that fill, but do not overflow the div. Then you have an upper bound on the number characters you need to send to always fill the div. Truncate each article in your slider to that number. You could add 10 characters if you want to ensure overflow and then use overflow hidden or ellipses or whatever.