Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Table Cell Width and Content Auto Fit

Status
Not open for further replies.

fox12

Programmer
Jan 18, 2005
62
US
I have problems in printing all contents of my tables. A few right columns are not printed on a hard copy. I want to achieve this work-around.

Since some columns have a big string, while others take few space, I want to limit the max width for each column.

If a text string falls within the max width, the cell shall auto shrink to fit the content.

If a text string falls out of the max width, the data in a cell shall wrapping to the next line.

How can I achieve this?

Thanks.
 
How is the table built? Client-side or server-side? Using what technology?

You could have a seperate stylesheet for printing.

 
Code:
<style>
td
{
width:100px;
word-wrap: break-word;       /* Internet Explorer */
white-space: normal;         /* Firefox */
white-space: -moz-pre-wrap;  /* Other Mozilla, since 1999 */
white-space: pre-wrap;       /* css-3 */
white-space: -pre-wrap;      /* Opera 4-6 */
white-space: -o-pre-wrap;    /* Opera 7 */
}
</style>
<table border="1"><tr><td> 
Maybe you can make it browser compatible.
</td></tr></table>

Clive
 
ClieveC,
I understand what your code is trying to achieve. However, it seems that it still can not for a long word string like:
"/export/home/username/customers/reports/payments/custid" can be wrapped if appearing in a column. since this string is exceeding the maximum length of a column, I'd like the string can be wrapped to the next line breaking either at any letter or regularly at the forward slash so as to make the whole page be printable.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top