Results 1 to 3 of 3

Thread: Wrap text in table-cell

  1. #1

    Thread Starter
    Hyperactive Member onerrorgoto's Avatar
    Join Date
    Aug 1999
    Location
    Sweden
    Posts
    330

    Wrap text in table-cell

    I'm trying to imitate the listview from MS in my page but have some problem with the size of cells in my table.

    Q1.
    I dont want the size of my "header"-cells to expand if the text is to large. I want the text to wrap instead. I have tried to set the td-width to px instead of % but that didn't work.

    Q2.
    Is there any javascript that lets the user resize the width of the
    cells by dragging the border or dbl-kclick like in the listview?

    VB Code:
    1. <table border="1" width="50%" cellspacing="0" cellpadding="0">
    2.   <tr>
    3. <!-- header-->
    4.     <td width="100%">
    5.       <table border="0" width="100%" cellspacing="0">
    6.         <tr>
    7.           <td width="22%" bgcolor="#FFFF99">
    8.             <p align="center">A</p>
    9.           </td>
    10.           <td width="22%" bgcolor="#FFFF99">
    11.             <p align="center">B</p>
    12.           </td>
    13.           <td width="22%" bgcolor="#FFFF99">
    14.             <p align="center">C</p>
    15.           </td>
    16.           <td width="22%" bgcolor="#FFFF99">
    17.             <p align="center">D</p>
    18.           </td>
    19.           <td width="5%"  bgcolor="#FFFF99">&nbsp;</td>
    20.         </tr>
    21.       </table>
    22.     </td>
    23.   </tr>
    24.   <tr>
    25. <!-- Content -->
    26.     <td width="100%">
    27. <span style='OVERFLOW: auto; WIDTH:100%; HEIGHT:170; BORDER-RIGHT: 1pt solid; BORDER-TOP: 1pt solid; BORDER-LEFT: 1pt solid; BORDER-BOTTOM: 1pt solid'>
    28. <table align="left" border="1" width="100%">
    29.   <tr>
    30.     <td width="25%">A1</td>
    31.     <td width="25%">B1</td>
    32.     <td width="25%">C1</td>
    33.     <td width="25%">D1</td>
    34.   </tr>
    35.   <tr>
    36.     <td width="25%">A2</td>
    37.     <td width="25%">&nbsp;</td>
    38.     <td width="25%">&nbsp;</td>
    39.     <td width="25%">&nbsp;</td>
    40.   </tr>
    41.   <tr>
    42.     <td width="25%">A3</td>
    43.     <td width="25%">&nbsp;</td>
    44.     <td width="25%">&nbsp;</td>
    45.     <td width="25%">&nbsp;</td>
    46.   </tr>
    47.   <tr>
    48.     <td width="25%">A4</td>
    49.     <td width="25%">&nbsp;</td>
    50.     <td width="25%">&nbsp;</td>
    51.     <td width="25%">&nbsp;</td>
    52.   </tr>
    53.   <tr>
    54.     <td width="25%">A5</td>
    55.     <td width="25%">&nbsp;</td>
    56.     <td width="25%">&nbsp;</td>
    57.     <td width="25%">&nbsp;</td>
    58.   </tr>
    59.   <tr>
    60.     <td width="25%">A6</td>
    61.     <td width="25%">&nbsp;</td>
    62.     <td width="25%">&nbsp;</td>
    63.     <td width="25%">&nbsp;</td>
    64.   </tr>
    65.   <tr>
    66.     <td width="25%">A7</td>
    67.     <td width="25%">&nbsp;</td>
    68.     <td width="25%">&nbsp;</td>
    69.     <td width="25%">&nbsp;</td>
    70.   </tr>
    71.   <tr>
    72.     <td width="25%">A8</td>
    73.     <td width="25%">&nbsp;</td>
    74.     <td width="25%">&nbsp;</td>
    75.     <td width="25%">&nbsp;</td>
    76.   </tr>
    77. </table>
    78. </span>
    79.     </td>
    80.   </tr>
    81. </table>
    Onerrorgoto

    Dont be to optimistic, the light at the end of the tunnel might be a train

  2. #2
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    A1) you have to set the pixels in the width and not percentages. the text in the cell has to be broken and cannot be continious.

    A2) no you cannot resize a table. maybe a div but not a table.

    you can not yuse a span tag like that. span tags are for text and not to hold things like a table. you want a div tag as that will hold it and also use the overflow property like you want. also div tag is a block level element so you might have better luck on getting it to resize by the user if you hook some javascript or DHTML on it.

    look at http://www.dhtmlcentral.com/ as they use what you want.

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    A span is an inline element and may not contain anything but inline elements (that is, no tables, no blocks and of course no table or list parts).
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width