html - Fluid and Fixed Columns Table -


i have table on layout has 5 columns, 3 of them should fixed width in px , other 2 should fluid.

it sounded simple @ first, problem 2 fluid columns should behave differently.

the last column should stretch as can fit contents, never hidden, shouldn't ever leave empty space. , middle column should occupy free space can find, overflow hidden in case last 1 needs grow larger.

table diagram

i tried make work css, couldn't manage make work... there way pure css or need js?

edit

that's got far:

html

<table>     <tr>         <td class="fixed">fixed</td>         <td class="fixed">fixed</td>         <td class="fluid hidden">fluid</td>         <td class="fixed">fixed</td>         <td class="fluid visible">this content should visible</td>     </tr>     </table> 

css

table{    width: 100%;    table-layout: fixed; }  td{     padding: 10px;       white-space: nowrap; }  .fixed{     background-color: #ddd;     width: 60px; }  .fluid{     background-color: #aaa; }  .visible{  }  .hidden{     overflow:hidden; } 

http://jsfiddle.net/kzvbx/

it works expected. except last column.

maybe can help, maybe not.

first, use divs instead of tr/td. don't have need using tables since css introduced, , i'm rather surprised people still do. there reason, please not take criticism.

if use divs, edit section of code:

.visible {   overflow:visible;   min-width: 210px; } 

that make sure div @ least 210 pixels wide no matter what. should work. btw, if table on page , div or td unique in sense has minimum height, may want use id instead of class. make code cleaner , more elegant. hope helps.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -