3 columns, middle one with flexible width

后端 未结 1 1461
天涯浪人
天涯浪人 2020-12-13 02:31

I\'d like to have a layout that consist of three adjacent divs. Side divs have static width (it may change via javascript) and center div fills a remaining area. When the fi

1条回答
  •  抹茶落季
    2020-12-13 03:03

    You can do that by floating col1 and col3 to the left and to the right, with a fixed width.

    Then add a left and right margin to col2 equal to the width of col1 and col3.

    This gives you three columns; col1 and col3 having a fixed width and col2 filling the available width:

    col2's content box in blue, and its margins in yellow
    (col2's content box in blue, and its margins in yellow)

    col3
    col1
    col2
    .container { overflow: hidden; } .right { float: right; width: 100px; } .left { float: left; width: 100px; } .middle { margin: 0 100px; }

    Try it here: http://jsfiddle.net/22YBU/

    BTW if you need display: table, display: table-row and display: table-cell, use a table ;-)

    0 讨论(0)
提交回复
热议问题