S
S
sadaffairs2017-02-13 19:55:27
css
sadaffairs, 2017-02-13 19:55:27

Why doesn't the last flex-item keep the width of other flex-items?

The code.
Try changing the screen width - the blocks inside the flex container adjust to the width and move to the next row. The problem is that the boxes in the last row of flex items don't keep their 150px width, stretching to fill all the empty space left. How to make sure that flex-items from the last row do not take up all the free space?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Sergey delphinpro, 2017-02-13
@sadaffairs

In certain cases - you can: codepen.io/anon/pen/mRvdeK
(Certain cases depend on the number of item blocks and the width of the container)

A
Andrey Fedorov, 2017-02-13
@aliencash

Because you let the items stretch - flex: 1 1 150px;
Replace withflex: 0 1 150px;

D
Denis Ineshin, 2017-02-13
@IonDen

This is the behavior of flex items as conceived by the authors.
You can control their size within certain limits by setting a priority and so on. But their width cannot be fixed.

C
ch-aqwer, 2017-02-13
@ch-aqwer

Flex elements cannot be given margins.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question