How to create a 3 columns fluid fixed fluid layout?

后端 未结 3 1883
名媛妹妹
名媛妹妹 2020-12-16 04:41

I\'m looking for a 3 column css layout, with 1 fixed section at the middle and 2 fluid sidebar around it:

http://www.uploadup.com/di-UEFI.png

middle has 250p

3条回答
  •  甜味超标
    2020-12-16 05:04

    You can try to use inline-blocks for it. They are used rather rarely, but sometimes they are pretty good for layouts.

    So, look at this: http://jsfiddle.net/kizu/UUzE9/ — with inline-blocks you can create layouts with any number of fixed and fluid columns. The algorithm:

    1. At first, you add the padding equal to the sum of all the fixed columns to the wrapper. In your case — 250px.
    2. Then, you add min-width to the wrapper equal to the sum of all the fluid columns' min-width.
    3. Then, you add white-space: nowrap to the wrapper, so the columns won't jump.
    4. And then just add the all columns that you need.

    If you need support for IE7 and lesser, there are some additional things to know except for common inline-block fix:

    1. You must return white-space: normal to the inner child of a column, or the columns won't stay on one line.
    2. There can appear a phantom scroll in IE, maybe there is a better way to remove it, but I just use overflow: hidden on some wrapper.

    Enjoy :)

提交回复
热议问题