Last active
July 20, 2020 08:23
-
-
Save chrisryana/f4733ec04a4019ece36c01d59e92fc98 to your computer and use it in GitHub Desktop.
Миксины для разработки
This file contains hidden or 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
// Миксин реализует грид систему внутри flex-контейнера | |
// $cols - количество блоков в одном ряду | |
// $margin - отступ между блоками в % | |
@mixin grid-element($cols, $margin) { | |
margin-bottom: $margin; | |
// Если больше 5 блоков в ряду, то растягивать на всю ширину | |
@if($cols >= 5) { | |
width: 100%; | |
margin-right: 0; | |
} | |
@else { | |
width: ((100% - (($cols - 1) * $margin)) / $cols); | |
margin-right: $margin; | |
} | |
&:nth-hild(#{$cols}n) { | |
margin-right: 0; | |
} | |
} | |
// Пример: | |
.grid { | |
display: flex; | |
flex-wrap: wrap; | |
&__element { | |
@include grid-element(4, 2%); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment