Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Three-column CSS layout - fixed/max./variable width

I'm having trouble getting the following three-column layout to work:

    A              B              C
+-------+-------------------+------------+
|       |                   |            |
| Fixed | Use unused space  |  Resizable |
|       |                   |            |
+-------+-------------------+------------+

Where:

  • A is fixed width.
  • B uses any available space in the container not used by the columns A and C.
  • C contains content which may change width and need to "push" B to a different width.

Here is my best attempt at creating this: http://jsfiddle.net/x3ESz/

All the other topics I have looked at suggest having all three as floating with B using margins to prevent wrapping, but this doesn't allow for C to resize B based on C's content (as a value must be given for B's right margin).

I also really want to avoid resorting to JS to achieve this.

like image 564
Alex Avatar asked Feb 06 '12 19:02

Alex


1 Answers

This can easily be solved by adding overflow: hidden to #div_middle and removing the margins:

#div_middle {
    overflow: hidden;
    border:1px solid #0F0;
}

See: http://jsfiddle.net/thirtydot/x3ESz/1/

This works in all modern browsers and IE7+.

like image 196
thirtydot Avatar answered Sep 21 '22 12:09

thirtydot