scss dynamic variable code example
Example: scss dynamic variable
/*Sass ( Scss ) does not allow variables to be created or accessed dynamically.
However, you can use lists for similar behavior.*/
$list: 20px 30px 40px;
@mixin get-from-list($index) {
width: nth($list, $index);
}
$item-number: 2;
#smth {
@include get-from-list($item-number);
}
/*OutPut*/
#smth {
width: 30px;
}