Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
Placing text in a block with maximum width
Old 03-31-2010, 10:49 AM Placing text in a block with maximum width
Skilled Talker

Posts: 83
Trades: 0
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
killerwhale65 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-31-2010, 05:30 PM Re: Placing text in a block with maximum width
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Quote:
Is there any better way to do this?
As far as I know, no.
Beside, a user that have text zoomed in will screw your computation too.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 04-01-2010, 08:14 AM Re: Placing text in a block with maximum width
Skilled Talker

Posts: 83
Trades: 0
ok, i was afraid so.

The text zoom is by the way not an issue, as it's for a web-application that only me will be running.
killerwhale65 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Placing text in a block with maximum width
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.26109 seconds with 12 queries