hi i have many variables with colors. so want do something like this:
$culture: #00CC66;
$party:#CC9900;
@each $i in culture, party {
.bl_#{$i}{
border-left-color: #{$#{$i}};
}
}
for print:
bl_culture{border-left-color:#00cc66}
bl_party{border-left-color:#cc9900}
How can ido it?
thanks
Interpolation can be used almost anywhere in a Sass stylesheet to embed the result of a SassScript expression into a chunk of CSS. Just wrap an expression in #{} in any of the following places: Selectors in style rules. Property names in declarations. Custom property values.
Exporting variables from SCSS stylesheet $myCustomVariable: #424242; After we defined anywhere in our SCSS stylesheet this variable, we are working with two custom SCSS functions. You should use the define-custom-property($name, $value) which accepts 2 parameters to define a new custom variable for export.
Mixin do some kind of styling which can be used again again in your whole styling and same you can use variable as much as you can. Functions and Mixins are different. One returns value while the other is used like a macro to substitute.
SASS 3.3 UPDATE
With some new functionality from sass 3.3 you can choose your variable names and do away with the annoying nth()
@each $name, $color in(
'red' $red,
'green' $green,
) {
.color-#{$name} {
background-color: $color;
}
}
ORIGINAL
It's a bit of a pain but you can get by with a list and then for looping through that.
For example:
$colorList:
"red" $red,
"green" $green
;
@each $i in $colorList{
.color-#{nth($i,1)}{
background-color:nth($i,2);
}
}
Having pre defined these color vars elsewhere you get:
.color-red{
background-color:#FF0000
}
.color-green{
background-color:#00FF00
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With