3

so I am trying to have the overflow property working for a div inside a td. However, I am setting the width of the td in terms of percentages. Therefore, I can't set the width of the div (inside the td) with a fix number of pixels, since I will not know it in advance.

<table id="table">
<thead>
    <tr> 
        <th>column 1</th>
        <th>column 2</th>
    </tr>
</thead>
<tbody>
    <tr>
        <td><div class="cell">Aaaaaaaaaaaaaabbbbbbbbba</div></td>
        <td><div class="cell">bbbbbbbbbbbbbaaaaaaaaaaabb</div></td>
    </tr>
 </tbody>
</table>​


#table {
     width:100px !important;
}

th {
   width:16% !important;
   border: 1px solid black;
}

.cell{
    width:100%;
     overflow: hidden;
    text-overflow: ellipsis;
    -o-text-overflow: ellipsis;
    -webkit-text-overflow: ellipsis;
    white-space: nowrap;
   }

http://jsfiddle.net/2Sync/

Any ideas?!

Thanks a lot!

abisson
  • 4,365
  • 9
  • 46
  • 68

2 Answers2

6

You may want to try adding following css rules:

#table{
    table-layout:fixed;
    overflow:hidden; 
    white-space: nowrap; 
}

Please check more in this post.

Community
  • 1
  • 1
woodykiddy
  • 6,074
  • 16
  • 59
  • 100
0

Nevermind... I used table-layout:fixed; and it worked!

abisson
  • 4,365
  • 9
  • 46
  • 68