I would like to write a sass loop like so.
fractions: '';
@for $i from 1 through 4 {
$fractions : $fractions + 1fr + '';
.grid-#{$i} {
grid-template-columns: fractions;
display: block;
}
}
I would like the output to be something like,
.grid-1 {
grid-template-columns: 1fr;
}
.grid-4 {
grid-template-columns: 1fr 1fr 1fr 1fr;
}
not
.grid-1 {
grid-template-columns: " 1fr";
}
.grid-4 {
grid-template-columns: " 1fr 1fr 1fr 1fr";
}
I'm looking for a sass utility/function that I can use to remove the quote around the strings.
1. quote($string) Function: This function adds the quotes to the unquoted string and returns the quoted string.
Interpolation allows us to interpolate sass expressions into a simple SASS or CSS code. Means, you can define ( some part or the whole ) selector name, property name, CSS at-rules, quoted or unquoted strings etc, as a variable. Interpolation is a new principle and it is widely used in SASS.
SassScript is a script which allows us to compute CSS selector, property or value using Sass expression. We'll look at expressions in this chapter and explore data types, SassScript control directives, operations and functions in the next few chapters. All of these can be use in SassScript.
$fractions:'';
@for $i from 1 through 4 {
$fractions : $fractions + 1fr + ' ';
.grid-#{$i} {
grid-template-columns: #{$fractions};
display: block;
}
}
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