Forked from ihorduchenko/Amount of flex-items per row
Created
October 3, 2018 17:56
-
-
Save mthony2002/7d73a45d20788060a376274cbc4974d9 to your computer and use it in GitHub Desktop.
How to adjust the amount of flex-items per row
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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; | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment