Expand a div to fill the remaining width

前端 未结 21 1211
一生所求
一生所求 2020-11-21 22:21

I want a two-column div layout, where each one can have variable width e.g.

21条回答
  •  礼貌的吻别
    2020-11-21 23:03

    Use calc:

    .leftSide {
      float: left;
      width: 50px;
      background-color: green;
    }
    .rightSide {
      float: left;
      width: calc(100% - 50px);
      background-color: red;
    }
    a
    b

    The problem with this is that all widths must be explicitly defined, either as a value(px and em work fine), or as a percent of something explicitly defined itself.

提交回复
热议问题