-
-
Save indreklasn/e4d9f5c337e1bbe38bca322aa4b9beb6 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% / 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