So imagine I have the following Markup
<div class="container">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
And the following styles (SASS)
@mixin max-width($width) {
@media screen and (max-width: $width) {
@content;
}
}
.container {
display: flex;
@include max-width(992px) {
number: 4; //Hypothetical property that is supposed to control number per row
}
@include max-width(640px) {
number: 2; //Hypothetical property that is supposed to control number per row
}
}
.item {
background-color: tomato;
padding: 20px;
margin-right: 20px;
flex: 1;
}
Is there a real Flexbox CSS alternative to my hypothetical number
property that can control how many items to show per row ?
The float-like grid was handy because you could fit unlimited .items
per one .row
because of the width
. But with flexbox I have to use workarounds like numerous .row
classes to control the layout and number of items at different width. I've been lucky so far, but there are certain type of layout which will fail with such an approach.
Codepen link to demonstrate