-
-
Save payamomrani/fa6d5bfe4e0f15e7429860096e3a5886 to your computer and use it in GitHub Desktop.
Dynamically create classes with SASS (from http://www.paulund.co.uk/dynamically-create-css-classes-sass)
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
$colours: | |
"red" #FF0000, | |
"blue" #001EFF, | |
"green" #00FF00, | |
"yellow" #F6FF00; | |
@each $i in $colours{ | |
.#{nth($i, 1)}-background { | |
background: nth($i, 2); | |
} | |
.#{nth($i, 1)}-color { | |
color:nth($i, 2); | |
} | |
} |
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
.red-background { | |
background: #FF0000; | |
} | |
.red-color { | |
color: #FF0000; | |
} | |
.blue-background { | |
background: #001EFF; | |
} | |
.blue-color { | |
color: #001EFF; | |
} | |
.green-background { | |
background: #00FF00; | |
} | |
.green-color { | |
color: #00FF00; | |
} | |
.yellow-background { | |
background: #F6FF00; | |
} | |
.yellow-color { | |
color: #F6FF00; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment