CSS side by side div's auto equal widths

前端 未结 5 1650
独厮守ぢ
独厮守ぢ 2020-11-28 23:30
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-29 00:24

    It's not impossible. It's not even particularly hard, with the use of display: table.

    This solution will work in modern browsers. It won't work in IE7.

    http://jsfiddle.net/g4dGz/ (three divs)
    http://jsfiddle.net/g4dGz/1/ (two divs)

    CSS:

    #wrapper {
        display: table;
        table-layout: fixed;
    
        width:90%;
        height:100px;
        background-color:Gray;
    }
    #wrapper div {
        display: table-cell;
        height:100px;
    }
    

    HTML:

    one one one one one one one one one one one one one one one one one one one one one
    two two two two two two
    three

提交回复
热议问题