I have a table column that should be limited to a specific width - for example, 100 pixels. Sometimes the text in this column is wider than this and does not contain spaces. For example:
a_really_long_string_of_text_like_this_with_no_line_breaks_makes_the_table_unhappy
I would like to calculate the width of the text server side and add an ellipsis after the correct number of characters. The problem is that I have no data about the displayed text size.
For example, assuming the browser was Firefox 3 and the font was 12px Arial. What will be the width of the letter "a", the width of the letter "b", etc.?
Do you have data showing the pixel width of each character? Or a program to create it?
I think a smart one-time javascript script could do the trick. But I donโt want to waste time reinventing the wheel if someone else did it. Of course, I am not the first person to solve this problem.
javascript jquery html css font-size
Devon
source share