开发者

Flexible div blocks

I need a three column block such that, if more content in the center (middle column) - side blocks increased.

Now i have this http://s2.ipicture.ru/uploads/20110714/NQ6ZNRsB.png

HTML:

<div id="spoiler">
  <div class="left">1</div>
  <div class="middle">
    2<br />
    aaaaaaaaaaaaaaaaaaaaaaaaaa<br />
    hhhhhhhhhhhhhhhhhhhhhhhhh<br />
    aaaaaaaaaaaaaaaaaaaaaaaaaa<br />
    aaaaaaaaaaaaaaaaaaaaaaaaaa<br />
  </div>
  <div class="right">3</div>
</div>

CSS:

            #spoiler {
            width:500px;
        开发者_开发知识库}
        .left, .middle, .right {
            background:#ffdac0;
            height: auto !important;
            height: 100%; /* for IE6 */
        }
        .left {
            float:left;
            width:100px;
        }
        .middle {
            float:left;
            width:300px;
        }
        .right {
            float:right;
            width:100px;
        }

Help please!


I only changed the css.

http://jsfiddle.net/QvfwN/

    #spoiler {
    width:500px;
        background:#ffdac0;
        float: left;
}
.left {
    float:left;
    width:100px;
}
.middle {
    float:left;
    width:300px;
}
.right {
    float:right;
    width:100px;
}


Remove the background colour from .left, .middle, .right and put it on the #spoiler along with either a float left or have some clearing at the bottom:

    #spoiler {
        width:500px;
        background:#ffdac0;
        float: left;
    }
    .left, .middle, .right {
        height: auto !important;
        height: 100%; /* for IE6 */
    }
    .left {
        float:left;
        width:100px;
    }
    .middle {
        float:left;
        width:300px;
    }
    .right {
        float:right;
        width:100px;
    }

This will produce the image you're looking for.


Simply use a table with 3 TD. This way it will always expand. Divs are not meant to work with eachother like that since they are block elements.

I think it can be done, but the simpler solution is the use of a good ol fashion table :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜