Created
February 3, 2015 08:02
-
-
Save torounit/0daa8b73417ef7c0e0c1 to your computer and use it in GitHub Desktop.
Grid
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
$gutter: 20px !default; | |
$flex: true !default; | |
$colslist: 1, 2, 3, 4, 5, 6, 12; | |
@mixin grid-unit($num) { | |
@for $i from 1 through $num { | |
&_#{$i}of#{$num} { | |
width: percentage($i/$num); | |
flex-basis: percentage($i/$num); | |
} | |
&_offset_#{$i}of#{$num} { | |
margin-left: percentage($i/$num); | |
} | |
} | |
} | |
.l-grid { | |
margin-left: -1 * $gutter / 2; | |
margin-right: -1 * $gutter / 2; | |
@if $flex == true { | |
display: flex; | |
flex-wrap: wrap; | |
&_center { | |
align-items: center; | |
} | |
&_bottom { | |
align-items: flex-end; | |
} | |
} | |
&:after { | |
content: ""; | |
display: table; | |
clear: both; | |
} | |
&__u { | |
box-sizing: border-box; | |
padding: 0 $gutter / 2; | |
width: 100%; | |
@if $flex { | |
flex-grow: 0; | |
flex-shrink: 0; | |
} | |
@else { | |
float: left; | |
} | |
& { | |
@each $cols in $colslist { | |
@include grid-unit($cols); | |
} | |
} | |
@media #{$small-up} { | |
&_small { | |
@each $cols in $colslist { | |
@include grid-unit($cols); | |
} | |
} | |
} | |
@media #{$medium-up} { | |
&_medium { | |
@each $cols in $colslist { | |
@include grid-unit($cols); | |
} | |
} | |
} | |
@media #{$large-up} { | |
&_large { | |
@each $cols in $colslist { | |
@include grid-unit($cols); | |
} | |
} | |
} | |
} | |
&_collapse { | |
margin-left: 0; | |
margin-right: 0; | |
} | |
&_collapse &__u { | |
padding: 0; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment