Skip to content

Instantly share code, notes, and snippets.

@jzhang300
Created September 15, 2015 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jzhang300/a2161a7f9782ea6d7ac5 to your computer and use it in GitHub Desktop.
Save jzhang300/a2161a7f9782ea6d7ac5 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
<div class="container">
<div class="house"></div>
<div class="house"></div>
<div class="house"></div>
<div class="house"></div>
</div>
// ----
// libsass (v3.2.5)
// ----
// create simple grids of width 100%
@mixin simple-grid($divisions, $gutter: 1rem) {
$division-percentage: 100 / $divisions;
$gutter-balancer: (($divisions - 1) / $divisions) * $gutter;
$width: calc(#{($division-percentage)}% - #{($gutter-balancer)});
width: #{($width)};
margin-right: #{($gutter)};
&:nth-of-type(#{($divisions)}n) {
margin-right: 0rem;
}
}
.brick {
@include simple-grid(5);
}
@mixin grid($columns, $total-columns: 12, $gutter: 1/3) {
$total-width: 100;
$column-width: 3 * $total-width / (4 * $total-columns - 1);
$gutter-width: $column-width / 3;
$grid-width: $column-width * $columns + $gutter-width * ($columns - 1);
width: #{($grid-width)}%;
margin-right: #{($gutter-width)}%;
float: left;
}
.container {
background-color: red;
height: 100px;
width: 100%;
}
.house {
@include grid(3);
height: 100%;
background-color: blue;
&:nth-of-type(4n) {
margin-right: 0rem;
}
}
.brick {
width: calc(20% - 0.8rem);
margin-right: 1rem;
}
.brick:nth-of-type(5n) {
margin-right: 0rem;
}
.container {
background-color: red;
height: 100px;
width: 100%;
}
.house {
width: 23.40426%;
margin-right: 2.12766%;
float: left;
height: 100%;
background-color: blue;
}
.house:nth-of-type(4n) {
margin-right: 0rem;
}
<div class="container">
<div class="house"></div>
<div class="house"></div>
<div class="house"></div>
<div class="house"></div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment