SASS/SCSS LOOP FOR A SIMPLE GRID SYSTEM

* { box-sizing: border-box; } [class^="col-"] { float: left; // Sample styles margin-bottom: 1em; border: 1px solid #222; text-align: center; background: #BADA55; } // Total columns for layout $total-columns: 6; $col-widths: (); @for $i from 1 through $total-columns { @for $j from 1 through $i { $w: ($j/$i); // If the width doesn't already exist @if not index($col-widths, $w) { .col-#{$j}-#{$i} { width: $w * 100%; } // Add the width to the array $col-widths: append($col-widths, $w, comma); } } }

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.