|
Hello,
I need to display a list of business names. I have a colum for that that has a specific width. What i want is that business names that are too long to fit, display as:
"name of the bus..."
instead of "name of the business"
The approach i have taken so far is to determine the amount of characters with PHP, and based on that only display the first x characters. The problem with that is that it's not a fixed width font, so sometimes names are shortened even if they could be displayed entirely because they are by far not as long as the width that is available.
Another approach i have taken is to put the names in a span, and determine the width of the span with jquery, and then shorten it if its too long. Together with a css height and text-overflow: hidden, this again works for some. But others simply do not break because there are no spaces in the name. So this ends up in a span that is much too long and messes with the layout. Appearently i cannot shorten this.
Is there any better way to do this?
thanks!
Matt
|