PDA

View Full Version : Limiting a tables width...



StickSuicideDotCom
March 9th, 2002, 23:48
I'm doing some upgrades on a forum I made and I wanted to limit the width of the tables where people's posts are. Is there a way to set a maximum width a table can use? If somebody puts in, say, 200 consecutive "a"s, the table will get stretched. How can I prevent that?

meow
March 10th, 2002, 01:12
The answer you deserve for being lazy : view source on for instance this page. ;)

The friendly answer: yes, you can give tables a max width by using a width in pixels in <TD> and none in <TABLE>. I suspect that what you want is a % width in <TABLE> though.

Jan
March 10th, 2002, 01:33
meow I don't think the source on this BB is a good example as I have seen a few posts where you have to scroll to the right to view it all :eek:

meow
March 10th, 2002, 01:43
:rolleyes:
That when you use &#91;&#99;&#111;&#100;&#101;&#93;&#46;&#46;&#91;&#47;&#99;&#111;&#100;&#101;&#93; which works like <pre></pre>...but maybe you're right and he asks for some way to validate and control the input. :confused2

Jan
March 10th, 2002, 01:53
I can understand it with the [code] so it doesn't mess up the code, but stu's UPCT posts and LeX's sig file spring to mind, where you have to scroll over.

StickSuicideDotCom
March 10th, 2002, 15:37
I tried everything that everybody has said so far, but to no prevail. =(
I need to limit the maximum width that a table can go to, or somehow use SOMETHING to stop a consecutive string of characters from stretching out the frame.

Somebody has to know this....right?

meow
March 10th, 2002, 15:49
Yeah, Jan made me see what you meant. Sorry. :o

Wouldn't a script that stops them from posting if they have typed too many characters without a space work? I've searched my mailboxes because someone posted a neato js to a list recently but I don't find it. I'll post it if it turns up.
Perhaps you should ask in the CGI forum? There may be some server side solution.

spec
March 10th, 2002, 16:52
isn't wrap and nowrap something that would work?

PyschoPath
March 10th, 2002, 18:18
Don't use px, use %, if you use say, 80%, it will always take up 80 percent of the screen, now, pixels are different, you put 150 pixels, and your screen is 150 pixels ( god forbid ) it will take up most of your screen, now adjust the size to 1240 X 768, it won't take as much. Problem solved.

Dusty
March 10th, 2002, 18:27
...only that wasn't the problem. You could implement something like is done here with
. In the script itself you check for lines of consecutive characters past a certain length then insert a <br> to break them up. Maybe something like:
$text=~s/([^\s]{50})/$1<br>/g;Where "50" is how many characters to allow to be consecutively placed without a space between them before a break is made.

keith
March 10th, 2002, 18:47
maybe instead of a break tag, a space? that might wreak a bit less havok with the way the messages will be shown...

StickSuicideDotCom
March 10th, 2002, 19:30
I COULD program a little in there to check for string of characters longer than x characters, but a lot of the time, people have my codes for smileys and links etc. One code for a smiley (the size equivalent of a single character) can be up to 30 characters, depending on the name of the smiley. So it would take too much for me to program that stuff. I'm EXTREMELY lazy. I need an easy way. Sorry guys, but thanks for your help.

cheatpark
March 11th, 2002, 05:10
If the table is inside and you set the width to 100% it should be fine. Just use a <td> tag before the <table> tag.