Last active
February 17, 2021 11:59
-
-
Save IlanFrumer/98d9bea65d038731ea11e9772449422b to your computer and use it in GitHub Desktop.
Flex Gap Polyfill
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="parent"> | |
<div class="child">1</div> | |
<div class="child">2</div> | |
<div class="child">3</div> | |
</div> | |
</div> | |
<div class="container" dir="rtl"> | |
<div class="parent"> | |
<div class="child">1</div> | |
<div class="child">2</div> | |
<div class="child">3</div> | |
</div> | |
</div> |
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 flex-gap($row-gap, $column-gap: $row-gap) { | |
display: flex; | |
& > * { | |
display: flex; | |
flex-wrap: wrap; | |
margin-top: -$column-gap; | |
} | |
& > * > * { | |
display: flex; | |
margin-top: $column-gap; | |
} | |
&:not([dir="rtl"]) { | |
& > * { | |
margin-left: -$row-gap; | |
} | |
& > * > * { | |
margin-left: $row-gap; | |
} | |
} | |
&[dir="rtl"] { | |
& > * { | |
margin-right: -$row-gap; | |
} | |
& > * > * { | |
margin-right: $row-gap; | |
} | |
} | |
} |
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
.container { | |
@include flex-gap(10px); | |
// justify-content: center; | |
} | |
.parent { | |
// justify-content: center; | |
} | |
.child { | |
// width: 50px; | |
// heigth: 50px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Plnkr Example