B
B
BarneyGumble2017-07-17 10:42:38
css
BarneyGumble, 2017-07-17 10:42:38

How to stretch a block on Flexbox without touching the rest of the fixed ones?

Hello!
I have the following markup:

<style>
  .container {
    display: flex;
    justify-content: space-between;
  }

  .fix {
    width: 200px;
  }
</style>

<div class="container">
  <div class="fix"></div>
  <div class="flex"></div>
  <div class="fix"></div>
</div>

How do I make the boxes stretch to the full width of the .container so that my .fix boxes keep their fixed width of 200px? Because now all blocks are stretched automatically (as I understand it, depending on the content), and my fixed width is ignored

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Negwereth, 2017-07-17
@BarneyGumble

.container {
  display: flex;
}

.flex {
  flex: 1;
}

.fix {
  flex: 0 200px;
}

L
Lynn "Coffee Man", 2017-07-17
@Lynn

Probably you still need to read at least one article about flexes and specifically about the flex property.
It's enough

.fix {
  width: 200px;
  flex: none;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question