Make Div on right side fill out all available space

后端 未结 5 1347
清酒与你
清酒与你 2021-01-28 04:27

I want to create two divs beside each other, however I want the one on the left side to be 300px, and the right one to take up the remaining amount on the screen. How would that

5条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-28 05:13

    The most straight-forward (and I would say correct) way is to use display: table:

    #wrapper {
        display: table;
        width: 100%;
    }
    #left, #right {
        display: table-cell;
        color: white;
    }
    #left {
        background: blue;
        width: 300px;
    }
    #right {
        background: red;
    }
    
    

    http://jsfiddle.net/YbLZE/1/

    Try resizing the bottom right frame.

    Updated with HTML5 elements section and aside, which you should use if you have an HTML5 doctype. I have to remember to use those...

提交回复
热议问题