html - text-overflow not working with HTML5 -


this question has answer here:

the following code works desired on chrome. not on firefox or ie. adding <!doctype html> tag code, leads not working on chrome too. has text-overflow been deprecated or something? how can make compatible browsers , html5?

<head>  <style type='text/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;     table-layout:fixed; }  td {     overflow: hidden;     white-space: nowrap;     word-wrap:break-word;     text-overflow:ellipsis;     border: 1px solid black; } </style> </head> <body> <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>alotofdataikkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk</td>         <td>yes</td>     </tr> </table>  </body> 

this want.enter image description here

you have misused text-overflow property.

if want wrap text of element, have specify width or max-width of element browsers know how wrap text content.

[edited] example code:

<head>  <style type='text/css'> table {     display: block;     margin: 30px 0 auto 0;     /*width: 100%;*/     max-width: 900px;     text-align: left;     white-space: nowrap;     border-collapse: collapse;     z-index: -1;     table-layout:fixed; }  td {     overflow: hidden;     white-space: nowrap;     word-wrap:break-word;     text-overflow: ellipsis;     border: 1px solid black; }  .col1 {   width: 80px; } .col7 {   max-width: 300px; } .col8 {   max-width: 300px; } </style> </head> <body> <table>     <tr>         <th class="col1">col 1</th>         <th class="col2">col 2</th>         <th class="col3">col 3</th>         <th class="col4">col 4</th>         <th class="col5">col 5</th>         <th class="col6">col 6</th>         <th class="col7">col 7</th>         <th class="col8">col 8</th>         <th class="col9">col 9</th>         <th class="col10">col 10</th>     </tr>     <tr>         <td class="col1">some</td>         <td class="col2">data</td>         <td class="col3">stuff</td>         <td class="col4">foo</td>         <td class="col5">etc</td>         <td class="col6">whatever</td>         <td class="col7">stuff</td>         <td class="col8">alotofdataikkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk</td>         <td class="col9">yes</td>         <td class="col10">bar</td>     </tr>     <tr>         <td class="col1">some</td>         <td class="col2">data</td>         <td class="col3">stuff</td>         <td class="col4">foo</td>         <td class="col5">etc</td>         <td class="col6">whatever</td>         <td class="col8">alotofdataikkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk</td>         <td class="col7">stuff</td>         <td class="col9">yes</td>         <td class="col10">bar</td>     </tr> </table>  </body> 

here demo screenshot: enter image description here


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -