Make flex-grow expand items based on their original size

前端 未结 4 2057
再見小時候
再見小時候 2020-11-22 12:07

I have 3 buttons in a row which all vary in width. I want them to all gain width the same to fill the remaining width of the row, so the widest will still be wider than the

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 13:01

    Not sure if this is entirely what you are after, but if you just set flex-grow:1 instead of flex:1;, I think that is your required result:

    .row-flex {
      width: 100%;
      display: inline-flex;
      flex-direction: row;
    }
    
    .button {
      flex-grow: 1;
      padding: 10px;
      color: #fff;
      text-align: center;
    }
    
    .button--1 {
      background: red
    }
    
    .button--2 {
      background: green;
    }
    
    .button--3 {
      background: blue;
    }

提交回复
热议问题