1

I've got three columns in the table of width: 100%.

  • 2nd and 3rd column should be width: 100px no matter what
  • 3rd column should be as much as it needs (no wrapped lines), but nothing more.
  • 1st column should consume all the remaining space.

JSFiddle: http://jsfiddle.net/o66czLtj/4/

Please note both the 1st and the 4th column don't have the width specified, so their widths are counted automatically by the browser. However, I want the 1st column to be the most important, and take all the remaining space, but only after the 4th column was able to render itself without wrapping any lines.

Actual:

enter image description here

Expected:

enter image description here

How to achieve this without hard-coding the width of the 1st or the 4th column? Perfectly with CSS only.

Rationale: number of buttons in the 4th column is unknown. It may be 1, it may be 4.

Nowaker
  • 12,154
  • 4
  • 56
  • 62

2 Answers2

1

See this answer. If you give the 4th column width: 1px; white-space: nowrap; then it should occupy the minimum space it can without affecting its content.

.col4 {
  width: 1px;
  white-space: nowrap;
}
Community
  • 1
  • 1
gandaliter
  • 9,863
  • 1
  • 16
  • 23
0

Could you not just add

Float: right

To column 2 and 3?

See fiddle below :)

http://jsfiddle.net/r7b3hny7/

I think this is what you're after?

Benjamin
  • 347
  • 1
  • 12