![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Nov 2005
Posts: 149
Rep Power: 3
![]() |
table size limits
I know you can set the td widths and such, but when a word is too long, it just stretches the cell. For example...
<table width=100%>
<tr>
<td width=20%>
[put a reeeeeeally long word here]
</td>
</tr>
</table>That td cell will be as long as that word is, unless the word is smaller than the cell. Is there any way to fix that? I know PHP, in case that could be part of the solution. |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Nov 2005
Posts: 122
Rep Power: 4
![]() |
It's stretching because there is no white-space in long words
for the browser to wrap. There is no solution bar splitting the word up and hyphenating it.
__________________
"I'm going to become rich and famous when I invent a device that allows you to stab people in the face over the internet" |
|
|
|
|
|
#3 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
You can use the CSS overflow property, or you can use PHP's wordwrap function: http://nl2.php.net/wordwrap, which splits long words into smaller words.
|
|
|
|
|
|
#4 |
|
Hobbyist Programmer
Join Date: Nov 2005
Posts: 149
Rep Power: 3
![]() |
Arg. I was hoping there was some table attribute or something, so I wouldn't have to go and write my own wordwrap method (since I want it to wrap when the word gets to a certain pixel length, rather than a certain character amount).
|
|
|
|
|
|
#5 | |
|
Hobbyist Programmer
Join Date: Nov 2005
Posts: 122
Rep Power: 4
![]() |
Quote:
tell how many pixels the word will occupy in the client's browser. It is probably possible in JavaScript, but it'll be ugly...
__________________
"I'm going to become rich and famous when I invent a device that allows you to stab people in the face over the internet" |
|
|
|
|
|
|
#6 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Besides, what happens when the user adjusts (or tries to adjust) the text size in the browser? Changes resolutions? Resizes a window? Personally, I try to leave the user in control as much as possible while still having a presentable page.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#7 |
|
Professional Programmer
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 317
Rep Power: 4
![]() |
I must say I don't envy anyone trying to do something pixel-perfect with HTML. If you're starting to worry about the width in pixels of a character, you've got a fundamental design problem. You can't do it at all without incredibly hairy goings-on with server-side code and doing it in JS is no easier (and until MS pull their socks up "portable Javascript" is an oxymoron anyway). You'd almost be as well simulating a table that behaved the way you wanted it to with a Java applet.
(Don't do this by the way, it would be insane.) |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|