Two divs, one fixed width, the other, the rest

前端 未结 10 1217
死守一世寂寞
死守一世寂寞 2020-11-27 11:28

I\'ve got two div containers.

Whilst one needs to be a specific width, I need to adjust it, so that, the other div takes up the rest of the space. Is there any way I

10条回答
  •  天涯浪人
    2020-11-27 12:04

    It's 2017 and the best way to do it is by using flexbox, which is IE10+ compatible.

    .box {
      display: flex;
    }
    
    .left {
      flex: 1;  /* grow */
      border: 1px dashed #f0f;
    }
    
    .right {
      flex: 0 0 250px; /* do not grow, do not shrink, start at 250px */
      border: 1px dashed #00f;
    }
    Left
    Right 250px

提交回复
热议问题