Last active
July 20, 2018 12:38
-
-
Save eddiemoore/7078773 to your computer and use it in GitHub Desktop.
SASS Loop to generate CSS column classes
This file contains 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
$total-columns: 6; | |
$col-widths: (); | |
@for $i from 1 through $total-columns { | |
@for $j from 1 through $i { | |
$w: ($j/$i); | |
@if not index($col-widths, $w) { | |
.col-#{$j}-#{$i} { | |
width: $w * 100%; | |
} | |
$col-widths: append($col-widths, $w, comma); | |
} | |
} | |
} |
This file contains 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
.col-1-1 { width: 100%; } | |
.col-1-2 { width: 50%; } | |
.col-1-3 { width: 33.33333%; } | |
.col-2-3 { width: 66.66667%; } | |
.col-1-4 { width: 25%; } | |
.col-3-4 { width: 75%; } | |
.col-1-5 { width: 20%; } | |
.col-2-5 { width: 40%; } | |
.col-3-5 { width: 60%; } | |
.col-4-5 { width: 80%; } | |
.col-1-6 { width: 16.66667%; } | |
.col-5-6 { width: 83.33333%; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is not sass