Skip to content

Instantly share code, notes, and snippets.

@IlanFrumer
Last active February 17, 2021 11:59
Show Gist options
  • Save IlanFrumer/98d9bea65d038731ea11e9772449422b to your computer and use it in GitHub Desktop.
Save IlanFrumer/98d9bea65d038731ea11e9772449422b to your computer and use it in GitHub Desktop.
Flex Gap Polyfill
<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>
@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;
}
}
}
.container {
@include flex-gap(10px);
// justify-content: center;
}
.parent {
// justify-content: center;
}
.child {
// width: 50px;
// heigth: 50px;
}
@IlanFrumer
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment