Skip to content

Instantly share code, notes, and snippets.

@indreklasn
Forked from ozziexsh/_grid.scss
Created April 24, 2016 14:54
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 indreklasn/e4d9f5c337e1bbe38bca322aa4b9beb6 to your computer and use it in GitHub Desktop.
Save indreklasn/e4d9f5c337e1bbe38bca322aa4b9beb6 to your computer and use it in GitHub Desktop.
SCSS Grid Component
$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% / 12 * #{$x});
}
.#{$breakpoint}-offset-#{$x} {
margin-left: calc(100% / 12 * #{$x});
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment