1

I want to achieve this:

I have a table for which columns I want to be able to set a fixed width each in px and % (if the content of a cell is larger than specified, the column is allowed to resize). A column I do not set a width for should resize by its content.

I tried this:

  1. I set table-layout to fixed, and used the width style on the cells. This works perfectly when I set the width of the table as well. But I cannot set the width of the table, since it might shrink columns so that their content overflows.
    Example: http://jsfiddle.net/zdY94/

  2. I use min-width on the cells, which works only with px values and not with %. The examples are available here: px: http://jsfiddle.net/2bNAz/ %: http://jsfiddle.net/2bNAz/1/

So, is there any possibility of having a table which behaves like table-layout: auto, but with the possibility to specify the width for specific columns in px and %?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Kai Hartmann
  • 3,106
  • 1
  • 31
  • 45

1 Answers1

0

The second answer offers a workable solution Set the table column width constant regardless of the amount of text in its cells?

Put a div inside the td. you can set width on the div

<td><div style="width: 50px" > blah blah</div></td>
Community
  • 1
  • 1
actual_kangaroo
  • 5,971
  • 2
  • 31
  • 45