Skip to content

Instantly share code, notes, and snippets.

@rogerramosme
Forked from ihorduchenko/Amount of flex-items per row
Last active October 1, 2018 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogerramosme/9911014284e41795b321b65774eb0d85 to your computer and use it in GitHub Desktop.
Save rogerramosme/9911014284e41795b321b65774eb0d85 to your computer and use it in GitHub Desktop.
Sass: How adjust amount of flex-items per row
<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>
@mixin max-width($width) {
@media screen and (max-width: $width) {
@content;
}
}
.container {
position: relative;
display: flex;
flex-flow: row wrap;
}
.item {
background-color: tomato;
box-sizing: border-box;
padding: 20px;
outline: 2px solid blue;
flex: 1;
}
@include max-width(992px) {
.item {
flex-basis: 25%;
background-color: red;
}
}
@include max-width(640px) {
.item {
flex-basis: 50%;
background-color: green;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment