S
S
skuvaWeb2018-06-01 15:53:05
css
skuvaWeb, 2018-06-01 15:53:05

How to arrange elements evenly on the grid?

I have a container which has the following properties

display: flex;
justify-content: space-between;

The element inside It turns out the following On large screens I want to show 3 in a row, but if I set the inner element To the second container, where only 2 elements due to the "space-between" property pushes the elements to the corners, and in the center there is an empty space (screen below ) Question How to make it so that if there are three or more elements in the container, they stand in turn with equal indents, and if there are two, they follow each other?
flex: 0 1 calc(50% - 6px)
5b1140ce999a2535378000.png
flex: 0 1 calc(33.333% - 12px)
5b1141571f196415838163.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikhail Zakharov, 2018-06-01
@cashalot

Use not space-between, but flex-start. It's just that the blocks will have to set some kind of margin so that they don't stick.

A
Alexey Zakharov, 2018-06-01
@konratnox

you can do this, I think you will figure it out
https://jsfiddle.net/konratnox/w0o4tc83/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question