Search code examples
csscss-tablestablelayout

table-layout: fixed ignores td's min-width


I have a project which requires a table that includes both fixed-width and flexible-width columns.

Some of the columns need to be 80px in width always, no matter what the width of the browser.

The rest of the columns need to be a flexible width, but all be of equal width, with a min-width of 75px;

By adding table-layout:fixed; to the table I am able to get the flexible width cols to all have equal widths, BUT then the table ignores the td's min-width attribute.

If I remove the table-layout:fixed, the min-width works but the flexible width cols all have different widths (based upon the length of the text they contain).

The number of columns vary based upon data pulled from db.

I have put an example of the table with table-layout:fixed and min-width on jsfiddle: http://jsfiddle.net/7d2Uj/

Any ideas how to get min-width to work in this situation, or why this is occurring?


Solution

  • You need to be using width, not min-width for the fixed width columns, and you should set the width of the remaining columns to a percentage based on the number of columns. In your case, you had 6 columns, so I set it to 16.66%.

    Working example: http://jsfiddle.net/6vw66/