How to make a stable two column layout in HTML/CSS

前端 未结 3 596
孤街浪徒
孤街浪徒 2020-12-07 10:28

I want a container with two columns. Details:

The container

  • Width should adjust to 100% of its parent element (easily accomplished).
  • Height
3条回答
  •  被撕碎了的回忆
    2020-12-07 10:51

    I could care less about IE6, as long as it works in IE8, Firefox 4, and Safari 5

    This makes me happy.

    Try this: Live Demo

    display: table is surprisingly good. Once you don't care about IE7, you're free to use it. It doesn't really have any of the usual downsides of

    .

    CSS:

    #container {
        background: #ccc;
        display: table
    }
    #left, #right {
        display: table-cell
    }
    #left {
        width: 150px;
        background: #f0f;
        border: 5px dotted blue;
    }
    #right {
        background: #aaa;
        border: 3px solid #000
    }
    

    提交回复
    热议问题