html - Cell overflow issues with table css -
so have table following code giving me trouble:
demo http://jsfiddle.net/hf3vt/
[html]
<table> <tr> <th style="width: 18%;">col 1</th> <th style="width: 12%;">col 2</th> <th style="width: 13%;">col 3</th> <th style="width: 7%">col 4</th> <th style="width: 7%">col 5</th> <th style="width: 6%">col 6</th> <th style="width: 5%">col 7</th> <th style="width: 13%">col 8</th> <th style="width: 16%">col 9</th> <th style="width: 3%">col 10</th> </tr> <tr> <td>some</td> <td>data</td> <td>stuff</td> <td>foo</td> <td>bar</td> <td>etc</td> <td>whatever</td> <td>stuff</td> <td>alotofdatainthiscell</td> <td>yes</td> </tr> </table>
[css]
table { display: block; margin: 30px 0 auto 0; width: 100%; max-width: 1300px; text-align: left; white-space: nowrap; border-collapse: collapse; z-index: -1; } td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
as can see trying have table sized dynamically according window until hits 1300px , has set size.
everything works fine until have data in single cell, causing become wider should reason. fix tried add ellipsis overflow did nothing when added it. remembered max-width needed added classes each cell match header percent sizes in max-width didn't work reason unless specified max-width in pixels. wondering if theres better way prevent ellipsis overflow thing without having specify on every cell, or if theres reason max-width doesn't work percents.
summary: long text ignoring width of cells , want turn ellipses when long not reason.
when align proper border display in manner. without border because align width every table header , not <td>
.
here updated fiddle:
Comments
Post a Comment