Answer the question
In order to leave comments, you need to log in
Where did I screw up with flex?
The bottom line is that let's say there are n-elements in the flex container and initially there are 3 of them, with a decrease in width 2, and then all 1.
Here is the flex container
.content-catalog__items
{
margin-top: 20px;
margin-bottom: 20px;
padding-right: 10px;
padding-left: 10px;
display: flex;
flex-flow: row wrap;
justify-content: space-around;
align-items: flex-start;
}
.content-catalog__items .content__new-products__item
{
flex: 1 1 240px;
margin-bottom: 20px;
}
Answer the question
In order to leave comments, you need to log in
For such cases, add a few more (how many depends on how many elements may be missing to a whole line) empty elements with zero height.
If you need to add only 1 or 2 such elements, as in your case, then you can get by with pseudo-elements.
https://jsfiddle.net/mdeoxjb6/
flex: 0 0 240px; / flex: 0 1 240px;
1) https://jsfiddle.net/po9n4tya/
2) https://jsfiddle.net/po9n4tya/1/
Alternatively, you need to limit the maximum block width, you can also write the width of the blocks, you can play around with media queries. For example:
.content-catalog__items .content__new-products__item {
max-width: 240px;
}
// Или
.content-catalog__items .content__new-products__item {
flex-basis: 50%;
width: 50%;
//на медии менять процентаж
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question