A
A
Alexander Rybakov2018-06-23 13:38:05
css
Alexander Rybakov, 2018-06-23 13:38:05

How to distribute blocks in a flex container?

Good afternoon!
It is necessary to distribute 3 blocks in flexbox: the
first and third in size, the middle one occupies all the remaining space
Between the blocks, the indent specified in pixels!
help

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vadim Kot, 2018-06-23
@vadimkot

https://codepen.io/anon/pen/jKKmWB

S
SagePtr, 2018-06-23
@SagePtr

Add flex-grow: 1 to the middle, flex-grow: 0 to the rest (or don't set, default is 0)

M
monochromer, 2018-06-23
@monochromer

.box {
  flex: 0 0 auto;
}

  .box:nth-child(2) {
    flex: 1 1 0%;
  }

  .box + .box {
    margin-left: 1rem;
  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question