Click to See Complete Forum and Search --> : lock table width


nuttynibbles
05-21-2007, 10:52 AM
hi, is there a way to lock the table width so that if the data to be displayed is too long, it will break line instead of displayin in one strectch causing the width to expand?:confused:

MitchEvans
05-21-2007, 11:02 AM
Give your table a fixed width eg

<table width='100'>

nuttynibbles
05-21-2007, 12:52 PM
if the table width is set, the table would not expand but the column would affect the other colums rite

jmack159
05-21-2007, 03:48 PM
but you can also set a width for your column too.

EDIT: I should say cells.

nuttynibbles
05-21-2007, 03:53 PM
erm quote me if im wrong, even if i set <td width=50> if the data gets too long, the cell would expand..

jmack159
05-21-2007, 04:10 PM
not really sure, never had that happen to me, but then again ive never LARGE amounts of text in a cell before. have you tried using css:
table {
width: 100px;
}

td {
width: 50px;
}

nuttynibbles
05-21-2007, 04:22 PM
nope not working..

jmack159
05-21-2007, 04:59 PM
try overflow with the css. do you need to display all of the data? or would it be appropriate to trim it down to certain number of words? if so, i have this function:
function trim_text($text, $threshold, $phrase="....."){
//cut the abstract down to a specified # of words

$atext = str_word_count($text, 2);
if(count($atext) >= $threshold){ // gotta cut
$ttext = array_keys($atext);
return substr($text, 0, $ttext[$threshold]-1).$phrase;
}else{ // put the whole thing
return $text;
}
}
i use that for a page where i show a list of scholarly papers to trim down abstracts. $threshold is # of words, $text is the text to trim, you can optionally give the phrase to append to the trimmed text. i use "...."

nuttynibbles
05-22-2007, 03:38 AM
because i would need to display customer details, i think it would be better to display all data. tks jmack159 i appreciate your help.. :)

bradgrafelman
05-22-2007, 06:18 PM
i think it would be better to display all dataThen you'll need some ClientSide Technology (I've moved your thread).

Try using a word-wrap property in the CSS:

.fixedWidthCell {
width: 50px;
word-wrap: normal;
}Or, if you want it to be 50 pixels no matter what (e.g. if you have long, unbroken words), change word-wrap from "normal" to "break-word".

nuttynibbles
05-31-2007, 12:38 PM
ok tks. i give it a shot