Can the flexbox make the first column a fixed width, and the second one extends to the remaining width?



  • Can the flexbox make the first column a fixed width, and the second one extends to the remaining width?



  • Of course you can. About:

    <div style="display: flex; flex-direction: row; align-content: flex-start;">
      <div style="flex-grow: 0; flex-shrink: 0; border: solid 1px; padding: 3px;">фиксированной ширины</div>
      <div style="flex-grow: 1; flex-shrink: 1; border: solid 1px; padding: 3px;">растягивается</div>
    </div>
    <div style="width: 150px; margin-top: 3px;">
       <div style="display: flex; flex-direction: row; align-content: flex-start;">
          <div style="flex-grow: 0; flex-shrink: 0; border: solid 1px; padding: 3px;">фиксированной ширины</div>
          <div style="flex-grow: 1; flex-shrink: 1; border: solid 1px; padding: 3px;">и сжимается</div>
      </div>
    </div>

    flex-grow: 0 Prohibits the left to try to grab a piece of free space.
    flex-grow: 1 Without competitors, it will allow the right to seize all the space. (In this case, any other number other than zero may be written)

    flex-shrink: 0 He won't let the left bore less than he needs.
    flex-shrink: 1 It's gonna squeeze right next to a reduction in width.

    That's a good story. http://habrahabr.ru/post/242545/
    I've met some good guidance, but I don't remember. Well, there's an infa online on this topic of good quality.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2