Last active
September 8, 2017 11:45
-
-
Save ozziexsh/dff51632618fa1eb2153 to your computer and use it in GitHub Desktop.
SCSS Grid Component
This file contains hidden or 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
$columns: 12; | |
$grid-breakpoints: ( | |
xs: 0, | |
sm: 544px, | |
md: 768px, | |
lg: 992px, | |
xl: 1200px | |
); | |
$container-max-widths: ( | |
sm: 576px, | |
md: 720px, | |
lg: 940px, | |
xl: 1140px | |
); | |
html { | |
box-sizing: border-box; | |
} | |
*, *:before, *:after { | |
box-sizing: inherit; | |
} | |
.row::before, | |
.row::after { | |
display: table; | |
content: " "; | |
clear: both; | |
} | |
.column, .columns { | |
position: relative; | |
float: left; | |
} | |
.container { | |
margin-left: auto; | |
margin-right: auto; | |
padding-left: 15px; | |
padding-right: 15px; | |
} | |
@each $breakpoint, $width in $grid-breakpoints { | |
@media(min-width: $width) { | |
@if map-has-key($container-max-widths, $breakpoint) { | |
.container { | |
max-width: map-get($container-max-widths, $breakpoint); | |
} | |
} | |
@for $x from 1 through $columns { | |
.#{$breakpoint}-#{$x} { | |
width: calc(100% / #{$columns} * #{$x}); | |
} | |
.#{$breakpoint}-offset-#{$x} { | |
margin-left: calc(100% / #{$columns} * #{$x}); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@austinpaquette nice catch. I'll update it :)