I am having a small problem. I was always using floating to arrange my elements. I am moving to flexbox, I made some examples and everything was good but I am making an example which things are not going well.
I have a container having between 1 to 12 products, 4 for each line. I made a simple example using only four and it is working, but now I am making an example with five elements, the first row looks fine, but the fifth element take 100% of the products container, but I want it to take only 25%, the sixth takes 25% and so on.
That what I see:
Here is my code :
<div class="container-2">
<div class="item-2">
...
</div>
<div class="item-2 p2-2">
...
</div>
<div class="item-2">
...
</div>
<div class="item-2 pp2">
...
</div>
<div class="item-2 pp2">
...
</div>
</div>
And That is my CSS :
.container-2 {
max-width: 1200px;
margin: 0 auto;
padding: 20px 15px;
display: flex;
flex-wrap: wrap;
flex-direction: row;
}
.item-2 {
padding: 0 15px;
flex: 1 0 25%;
margin-bottom: 40px;
}