How to make a div fill a remaining horizontal space?

前端 未结 25 1409
野的像风
野的像风 2020-11-22 00:45

I have 2 divs: one in the left side and one in the right side of my page. The one in the left side has fixed width and I want the one of the right side to f

25条回答
  •  迷失自我
    2020-11-22 01:24

    I had a similar problem and I found the solution here: https://stackoverflow.com/a/16909141/3934886

    The solution is for a fixed center div and liquid side columns.

    .center{
        background:#ffffd;
        width: 500px;
        float:left;
    }
    
    .left{
        background:#999;
        width: calc(50% - 250px);
        float:left;
    }
    
    .right{
        background:#999;
        width: calc(50% - 250px);
        float:right;
    }
    

    If you want a fixed left column, just change the formula accordingly.

提交回复
热议问题