This is a discussion on "Appending "..." after so many pixels in a string" within the Web Page Design section. This forum, and the thread "Appending "..." after so many pixels in a string are both part of the Design Your Website category.
|
|
|
|
|
![]() |
||
Appending "..." after so many pixels in a string
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Appending "..." after so many pixels in a string
Hi,
I have a table which has a fixed row length with many strings of many different lengths, which can only be on a single line. Currently I use "<div style='overflow: hidden; width: 100%; white-space: nowrap;'>" in the row to hide the end of the string if it's too long to fit, but I want to add a "..." just before it gets cut off. I know how to do this if the string is beyond a certain character length, but not pixel length which is what I'm after here. Thanks |
|
|
|
||||
|
Re: Appending "..." after so many pixels in a string
Do you use anything like PHP? If you do, you could use strlen().
|
|
|||
|
Re: Appending "..." after so many pixels in a string
Thanks for the reply, and yeah I do use PHP but I sort of wanna steer away from using strlen because it gets the length in characters, not pixels.
The problem being a string with say 15 W's is a lot different pixel wise than 15 i's. |
|
|||
|
Re: Appending "..." after so many pixels in a string
Well, currently with "<div style='overflow: hidden; width: 100%; white-space: nowrap;'>" it does that, and it doesn't look too strange, I also use a title attribute to show the full name.
I'm thinking it would require a bit of JavaScript work, which I'm pretty unfamiliar with. The only place I can remember this being done was on Web MSN's contact list, so if it's overly complicated, I'll just stick with what I have now |
|
||||
|
Re: Appending "..." after so many pixels in a string
If you are using width 100% you don't really have a good idea of what amount of pixels are being used, plus the browser size can be changed on the fly. I'd personally do a string check and if it is above a certain number of strings display the ... else don't. That's the only thing I can see that would work. Pixels are not going to work with percentages.
Last Blog Entry: Happy Holidays - A Non Offensive way to say Merry Christmas? WRONG! (Dec 11th, 2007)
|
|
|||
|
Re: Appending "..." after so many pixels in a string
Ah, the row is at a fixed length (500px) but the 100% is just the <div> inside the row. There was a comment on the php.net strlen doc that hopefully will do what I want.
Thanks everyone! |
|
||||
|
Re: Appending "..." after so many pixels in a string
Cheers!
Well good to see that you found a solution.
Last Blog Entry: Happy Holidays - A Non Offensive way to say Merry Christmas? WRONG! (Dec 11th, 2007)
|
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Creating a "tag" system to find relevant "related" pages | MrQuestions | PHP Forum | 3 | Mar 20th, 2008 23:06 |
| [SOLVED] Show "Image" Depends On User "Status"? | Monie | Classic ASP | 6 | Oct 16th, 2007 01:22 |
| ? IS "meta name="robots" content="?" necessary in pages ? | Love2Java | Starting Out | 6 | Aug 8th, 2007 13:48 |
| window.opener.document["nameForm"].getElementById("someid").value; doesnt work | drpompeii | JavaScript Forum | 0 | Feb 17th, 2007 23:09 |
| <option value="yes" class="x"> problem in Firefox | mameha1977 | Web Page Design | 1 | Jun 21st, 2006 11:20 |