SCSS Flexbox Grid

$grid-width: 64em; .wrap { display: flex; flex-wrap: wrap; overflow-x: hidden; max-width: $grid-width; width: 100%; margin: 0 auto; } $gap: 10px; @for $i from 1 through 12 { .col-sm-#{$i}, .col-md-#{$i}, .col-lg-#{$i} { display: inline-block; flex: 1; margin: 0 $gap/2; } .col-sm-#{$i} { max-width: calc(#{$i / 12 * 100%} - #{$gap}); min-width: calc(#{$i / 12 * 100%} - #{$gap}); } } .col-sm-12, .col-md-12, .col-lg-12 { margin: 0; } @media (max-width: 768px) { @for $i from 1 through 12 { .col-sm-#{$i}, .col-md-#{$i}, .col-lg-#{$i} { max-width: 100%; width: 100%; margin: 10px 0; padding: 0 10px; display: block; flex: none; } } }
Flexbox grid written in SCSS, with a media query to make items full width at 768px.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.