The left and right columns are fixed width: 180px
and 200px
respectively, and the middle column is liquid
, expanding to fill the available space.
I don't know how to make the div become column, I used tables before!
Please help.
The left and right columns are fixed width: 180px
and 200px
respectively, and the middle column is liquid
, expanding to fill the available space.
I don't know how to make the div become column, I used tables before!
Please help.
I would use display: table-cell;
to the center col and float
property to left and right cols like this: http://jsfiddle.net/z692auyL/
.left {
background-color: #ddf;
float: left;
width: 180px;
height: 65px;
}
.center{
background-color: green;
float: none;
height: 65px;
overflow: hidden;
display: table-cell;
}
.right{
background-color: cyan;
float: right;
height: 65px;
width:200px;
}
I find that a CSS Table layout works well for this sort of thing. It benefits from excellent x-browser support and avoids the need to use (and subsequently clear) floats or having to find a polyfill for the poorly supported calc()
. Furthermore, each column is automatically the same height.
.main {display:table; width:100%;}
.left, .center, .right {display:table-cell;}
.left {width:180px; min-width:180px; background:red;}
.right {width:200px; min-width:200px; background:blue;}
Working demo at: http://jsfiddle.net/u64xc9x4/
N.B. The min-width
is optional. Without it the 'cells' can be squished narrower if your page is smaller than the combined column width. This could be useful.