CSS - How to force elements to 100% of remaining/available space of parent element without extending beyond it?

后端 未结 2 854
时光说笑
时光说笑 2021-02-20 04:06

This seems like a really amateur question, in my opinion, but nonetheless it\'s still a frustrating anomaly.

This is actually the 2nd part of a 2 part problem. The firs

2条回答
  •  逝去的感伤
    2021-02-20 04:36

    I believe the proper solution to something like this is using a flexbox. Flexbox has great support the lately with all modern browsers.

    Use following for the parent

    .stretch-items {
      display: flex;
      flex-direction: column;  
    }
    

    And for the item that should grow

    .stretch-items .stretch {
       flex-grow: 1;  
    }
    

    Here is a codepen demonstrating it https://codepen.io/giorgosk/pen/NWWaqPO

提交回复
热议问题