The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> help with very annoying problem
jjd228
post Sep 28 2006, 12:22 PM
Post #1





Group: Members
Posts: 4
Joined: 28-September 06
Member No.: 258



i have a table with 1 row and 1 column. i need to set the width of this column to a fixed sixe that will not change. what is happening is that this cell is populated with information from a database. if the line is longer than the cell is wide, the whole thing stretches out and destroys that page. how can i make it so that the text wraps to the next line if its longer than the width of the cell?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jimlongo
post Sep 28 2006, 12:33 PM
Post #2


This is My Life
*******

Group: Members
Posts: 1,125
Joined: 24-August 06
From: t-dot
Member No.: 16



Use CSS to fix the width of the table
http://www.w3.org/TR/REC-CSS2/tables.html#width-layout
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Sep 28 2006, 12:51 PM
Post #3


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 18,139
Joined: 9-August 06
Member No.: 6



QUOTE(jjd228 @ Sep 28 2006, 07:22 PM) *

if the line is longer than the cell is wide, the whole thing stretches out and destroys that page.

If you by line mean a sequence of characters without spaces it will never wrap. In that case you need to do something to handle the length of the string.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jjd228
post Sep 28 2006, 02:24 PM
Post #4





Group: Members
Posts: 4
Joined: 28-September 06
Member No.: 258



QUOTE(jimlongo @ Sep 28 2006, 01:33 PM) *

Use CSS to fix the width of the table
http://www.w3.org/TR/REC-CSS2/tables.html#width-layout


ive tried usign 'table-layout' and it does not work, unless im applying it wrong. would you give me a small example?
for instance:

<table width="100">
<tr>
<td width="50">this is the text i want to wrap</td>
<td></td>
</tr>
</table>

if that text is longer than 50px it will simply push the width of the TD out and make it expand. i dont want that. i want it to wrap to the next line when it hits the 50px mark. how would i apply the styles to this table structure?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jimlongo
post Sep 28 2006, 02:36 PM
Post #5


This is My Life
*******

Group: Members
Posts: 1,125
Joined: 24-August 06
From: t-dot
Member No.: 16



with an in-line style declaration . . .
HTML
<html>
<head>
<style type="text/css">
<!--
table
{table-layout: fixed;}
-->
</style>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<title>Untitled</title>
</head>
<body>
<table border="2" width="80%">
<tr>
<td width="50">
if the text in this column is wider than 50 pixels it will rap unless like pandy says there is a "unbroken" string - in that case it will not wrap (see column 3)
</td>
<td width="50">
test
</td>
<td width="50">
testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest
testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest

</td>
</tr>
</table>
</body>
</html>



IPB Image

This post has been edited by jimlongo: Sep 28 2006, 02:38 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Sep 28 2006, 02:38 PM
Post #6


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 18,139
Joined: 9-August 06
Member No.: 6



The text wraps fine in the example you posted, so what about you show us the real deal where it doesn't wrap? tongue.gif

'table-layout: fixed' doesn't make anything wrap that wouldn't otherwise. On the contrary, if you don't know if there can be unbreakable strings or pictures wider than the allowed width, the construct will break. Browsers are wonky with this layout mode, too.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jjd228
post Sep 28 2006, 03:11 PM
Post #7





Group: Members
Posts: 4
Joined: 28-September 06
Member No.: 258



so in other words if there is no "enter" pressed, it wont wrap?

the "word-wrap: break-word;" tag WILL wrap even when there is no linebreak in the text, but its only supported in IE!!!!

so what do i do? i cant make people hit enter when theyre filling in a text box sad.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Sep 28 2006, 03:18 PM
Post #8


.
********

Group: WDG Moderators
Posts: 8,044
Joined: 10-August 06
Member No.: 7



QUOTE(jjd228 @ Sep 28 2006, 10:11 PM) *

i cant make people hit enter when theyre filling in a text box sad.gif


You can let a server-side script cut up strings after a certain length, e.g. with PHP: http://se2.php.net/manual/en/function.wordwrap.php
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jjd228
post Sep 28 2006, 03:24 PM
Post #9





Group: Members
Posts: 4
Joined: 28-September 06
Member No.: 258



wouldnt happen to have a vbscript example would ya? if not im gonna have to convert that mess
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 22nd February 2019 - 01:44 PM