Skip to content

Instantly share code, notes, and snippets.

@castastrophe
Last active September 12, 2017 20:27
Show Gist options
  • Save castastrophe/f6d07087bcde9f5c28651cfa8da1b0bf to your computer and use it in GitHub Desktop.
Save castastrophe/f6d07087bcde9f5c28651cfa8da1b0bf to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
> 1%
last 2 versions
<div class="container">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
<div class="box">5</div>
<div class="box">6</div>
<div class="box">7</div>
</div>
// ----
// Sass (v3.4.21)
// Compass (v1.0.3)
// ----
.container {
display: flex;
flex-flow: row wrap;
margin-bottom: -10px;
margin-right: -10px;
> * {
margin-right: 10px;
margin-bottom: 10px;
&:not(:nth-child(n+3)) {
flex-basis: calc(50% - 10px);
flex-grow: 1;
color: red;
}
&:nth-child(n+3) {
flex-basis: calc((100%/3) - 10px);
flex-grow: 0;
color: blue;
}
}
}
.box {
min-width: 200px;
min-height: 100px;
background: lightgray;
font-size: 2em;
display: flex;
align-items: center;
justify-content: center;
}
.container {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-flow: row wrap;
-ms-flex-flow: row wrap;
flex-flow: row wrap;
margin-bottom: -10px;
margin-right: -10px;
}
.container > * {
margin-right: 10px;
margin-bottom: 10px;
}
.container > *:not(:nth-child(n+3)) {
-webkit-flex-basis: calc(50% - 10px);
-ms-flex-preferred-size: calc(50% - 10px);
flex-basis: calc(50% - 10px);
-webkit-box-flex: 1;
-webkit-flex-grow: 1;
-ms-flex-positive: 1;
flex-grow: 1;
color: red;
}
.container > *:nth-child(n+3) {
-webkit-flex-basis: calc((100%/3) - 10px);
-ms-flex-preferred-size: calc((100%/3) - 10px);
flex-basis: calc((100%/3) - 10px);
-webkit-box-flex: 0;
-webkit-flex-grow: 0;
-ms-flex-positive: 0;
flex-grow: 0;
color: blue;
}
.box {
min-width: 200px;
min-height: 100px;
background: lightgray;
font-size: 2em;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
}
<div class="container">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
<div class="box">5</div>
<div class="box">6</div>
<div class="box">7</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment