jquery - Wide table in scrollable div squishing cells -


i have table arbitrary amount of columns , rows , <td> tags have height , width. issue when put in <div> overflow:scroll , width less width of table, table cells squished, though have specified width on them.

i've done bunch of testing , appears if specify width of table, looks fine. there's got css way of doing without specifying table width.

this gist of code , css along jsfiddle demo (the number of columns doesn't matter, long it's greater width of div

<div class="wrapper">     <table cellspacing="0" cellpadding="0" class="colors">         <tbody>             <tr>             <td><td>             <td><td>             <td><td>             <td><td>             <td><td>             <td><td>             <td><td>             <td><td>         </tbody>     </table> </div> 

css:

table.colors td {     width:25px;     height:25px;     font-size:.8em;     line-height:25px;     border:1px solid #c0c0c0;     padding:0;     margin:0; }  .wrapper {     overflow:scroll;     width:300px;     height:300px; } 

http://jsfiddle.net/nightcatbooks/l7gwwyl4/

specify min-width cells don't squished:

table.colors td {     width:25px;     min-width:25px; 

might not work on older browsers (ie7? not tested)

working fiddle: http://jsfiddle.net/pxth1hph/


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -