Skip to content

Instantly share code, notes, and snippets.

@artemsheludko
Created June 8, 2020 14:10
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 artemsheludko/6aa17827cf76bf14a9566314c0cdfd22 to your computer and use it in GitHub Desktop.
Save artemsheludko/6aa17827cf76bf14a9566314c0cdfd22 to your computer and use it in GitHub Desktop.
Grid
$columns: 12;
$container-base-width: 1200px;
$container-big-width: 1600px;
$container-offset: 20px;
$desktop: 992px;
$tablet: 768px;
$mobile: 576px;
$mq: ( $mobile:$columns, $tablet:$columns, $desktop:$columns );
.container,
.container-big {
max-width: $container-base-width;
padding-left: $container-offset;
padding-right: $container-offset;
margin: 0 auto;
&-big {
max-width: $container-big-width;
}
}
.row {
display: flex;
flex-wrap: wrap;
flex: 0 1 auto;
flex-direction: row;
box-sizing: border-box;
margin-left: ($base-spacing-unit * -1);
margin-right: ($base-spacing-unit * -1);
}
.col {
padding-left: $base-spacing-unit;
padding-right: $base-spacing-unit;
}
[class^="col-"] {
flex: auto;
}
@for $i from 0 through $columns {
.col-#{$i} {
width: percentage( $i / $columns );
}
}
@for $i from 0 through $columns {
.push-#{$i} {
margin-left: percentage( $i / $columns );
}
}
@for $i from 0 through $columns {
.pull-#{$i} {
margin-right: percentage( $i / $columns );
}
}
@each $key, $val in $mq {
// DESKTOP
@media(max-width: $desktop) {
@for $i from 0 through $columns {
.col-d-#{$i} {
width: percentage( $i / $columns );
}
}
@for $i from 0 through $columns {
.push-d-#{$i} {
margin-left: percentage( $i / $columns );
}
}
@for $i from 0 through $columns {
.pull-d-#{$i} {
margin-right: percentage( $i / $columns );
}
}
}
// TABLET
@media(max-width: $tablet) {
@for $i from 0 through $columns {
.col-t-#{$i} {
width: percentage( $i / $columns );
}
}
@for $i from 0 through $columns {
.push-t-#{$i} {
margin-left: percentage( $i / $columns );
}
}
@for $i from 0 through $columns {
.pull-t-#{$i} {
margin-right: percentage( $i / $columns );
}
}
}
// MOBILE
@media(max-width: $mobile) {
@for $i from 0 through $columns {
.col-m-#{$i} {
width: percentage( $i / $columns );
}
}
@for $i from 0 through $columns {
.push-m-#{$i} {
margin-left: percentage( $i / $columns );
}
}
@for $i from 0 through $columns {
.pull-m-#{$i} {
margin-right: percentage( $i / $columns );
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment