Kevin Powell - CommunityKP-C
Kevin Powell - Communityโ€ข10mo agoโ€ข
13 replies
MC23

Dynamyc SCSS classes with % value

Hello, I'm replacing a deprecated Angular library and I'm trying to create a class in this way:
$fxflexValues: (19, 100);
@each $value in $fxflexValues {
  .flex--fx#{$value} {
    flex: 1 1 #{$value}%;
    max-width: #{$value}%;
  }
}
But it gives me error: term expectedscss(css-termexpected). So I also tried:
$fxflexValues: (19, 100);
@each $value in $fxflexValues {
  .flex--fx#{$value} {
    flex: 1 1 #{$value + "%"};
    max-width: #{$value + "%"};
  }
}
But it doesn't seem to apply any class. What am I doing wrong?
Was this page helpful?