html - Overflow: hidden not working when TD, and TH width are specified -


i need help.

it seems td cell not respecting overflow: hidden in css. i've done recommended fixed layout of table specifying widths of th's , td's

any ideas?

<!doctype html> <html> <head>  <style type="text/css">  /*------------------------------------------------------------------ table style ------------------------------------------------------------------ */ table a:link {     color: #666;     font-weight: bold;     text-decoration:none; } table a:visited {     color: #999999;     font-weight:bold;     text-decoration:none; } table a:active, table a:hover {     color: #bd5a35;     text-decoration:underline; } table {     font-family:arial, helvetica, sans-serif;     color:#666;     font-size:12px;     background:#eaebec;     border-collapse:collapse;     border-spacing: 0;     table-layout: fixed; } table th {     padding:10px 10px 10px 10px;     border-bottom:1px solid #e0e0e0;     border-right: 1px solid #e0e0e0;     width: 160px;      background: #ededed; } table th:first-child {     text-align: left; } table tr:first-child th:first-child {     border-left: 0; }  table tr {     text-align: center; } table td:first-child {     text-align: left;     border-left: 0; } table td {     padding:10px;     border-bottom:1px solid #e0e0e0;     border-right: 1px solid #e0e0e0;     background: #fafafa;     width: 130px; } table tr:last-child td {     border-bottom: 0; }  table tr:hover td {     background: #f2f2f2;  }  #wrapper {     width: 740px;     height: 200px;     overflow-x: scroll;     overflow-y: scroll;     border: 1px solid rgb(205,205,205); } table thead {     position:fixed; } table td > div {     overflow: hidden;     white-space: nowrap; }   </style>  </head>  <body>  <div id="wrapper"> <table>      <!-- table header -->     <thead>         <tr>             <th>task details</th>             <th>firstname</th>             <th>progress</th>             <th>vital task</th>         </tr>     </thead>     <!-- table header -->      <!-- table body -->     <tbody>          <tr>             <td>create</td>             <td>&nbsp;</td>             <td>100%</td>             <td>yes</td>         </tr><!-- table row -->          <tr>             <td>take dog</td>             <td>&nbsp;</td>             <td>100%</td>             <td>yes</td>         </tr><!-- darker table row -->          <tr>             <td>waste half</td>             <td>&nbsp;</td>             <td>20%</td>             <td>no</td>         </tr>          <tr>             <td><div>feel inferior</div></td>             <td>&nbsp;</td>             <td>80%</td>             <td>no</td>         </tr>          <tr>             <td><div>some long text shouldn't resize box</div></td>             <td>&nbsp;</td>             <td>100%</td>             <td>yes</td>         </tr>          <tr>             <td><div>vow complete</div></td>             <td>&nbsp;</td>             <td>23%</td>             <td>yes</td>         </tr>          <tr>             <td>procrastinate</td>             <td>&nbsp;</td>             <td>80%</td>             <td>no</td>         </tr>          <tr>             <td><a href="#yep-iit-doesnt-exist">hyperlink example</a></td>             <td>&nbsp;</td>             <td>80%</td>             <td><a href="#inexistent-id">another</a></td>         </tr>      </tbody>     <!-- table body -->  </table> </div>  </body> </html> 

you needed rid of white-space here

table td > div {    overflow: hidden;    white-space: nowrap; } 

and added colgroups. better setting widths in columns , avoid issues

demo


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -