Skip to content

Instantly share code, notes, and snippets.

@euqueme
Last active October 30, 2019 03:19
Show Gist options
  • Save euqueme/ef0ea436bb151453ae23459e837c98f4 to your computer and use it in GitHub Desktop.
Save euqueme/ef0ea436bb151453ae23459e837c98f4 to your computer and use it in GitHub Desktop.
explaining grid in scss code
//VARIABLES
$xs: xs;
$sm: sm;
$md: md;
$lg: lg;
$xl: xl;
$breakpoint-xs: 575px;
$breakpoint-sm: 576px;
$breakpoint-md: 768px;
$breakpoint-lg: 992px;
$breakpoint-xl: 1200px;
$class-col: col;
$gutter-width: 1%;
$column-width: (88%/12);
//MAIN
@mixin grid-unit-normal($span) {
float: left;
margin-right: $gutter-width;
width: ($column-width * $span) + ($gutter-width * ($span - 1));
}
@mixin grid-unit($span) {
float: left;
margin-right: $gutter-width;
width: ($column-width * $span) + ($gutter-width * ($span - 1)) !important;
}
@for $i from 1 through 12 {
.#{$class-col}-#{$i} {
@include grid-unit-normal($i);
}
}
@for $i from 1 through 12 {
@media screen and (max-width: $breakpoint-xs) {
.#{$class-col}-#{$xs}-#{$i} {
@include grid-unit($i);
}
}
}
@for $i from 1 through 12 {
@media screen and (min-width: $breakpoint-sm) {
.#{$class-col}-#{$sm}-#{$i} {
@include grid-unit($i);
}
}
}
@for $i from 1 through 12 {
@media screen and (min-width: $breakpoint-md) {
.#{$class-col}-#{$md}-#{$i} {
@include grid-unit($i);
}
}
}
@for $i from 1 through 12 {
@media screen and (min-width: $breakpoint-lg) {
.#{$class-col}-#{$lg}-#{$i} {
@include grid-unit($i);
}
}
}
@for $i from 1 through 12 {
@media screen and (min-width: $breakpoint-xl) {
.#{$class-col}-#{$xl}-#{$i} {
@include grid-unit($i);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment