Div side by side without float

后端 未结 6 1208
自闭症患者
自闭症患者 2020-12-01 01:31

How can I make div \'left\' and \'right\' look like columns side by side?

I know I can use float:left on them and that will work... but on step 5 and 6 in here http

6条回答
  •  鱼传尺愫
    2020-12-01 01:38

    You can also use CSS3 flexbox layout, which is well supported nowadays.

    .container {
        display: flex;
        flex-flow: row nowrap;
        justify-content: space-between;
        background:black;
        height:400px;
        width:450px;
    }
    
    .left {
        flex: 0 0 300px;
        background:blue;
        height:200px;
    }
    
    .right {
        flex: 0 1 100px;
        background:green;
        height:300px;
    }
    

    See Example (with legacy styles for maximum compatiblity) & Learn more about flexbox.

提交回复
热议问题