[英]sass variable interpolation in each loop
trying to use variable inside each loop. 试图在每个循环中使用变量。 But doesn't seem like working for me
但似乎并不适合我
$font-size-40: .5rem;
$font-size-50: .625rem;
$font-size-60: .75rem;
$fonts: 40 50 60;
@each $font in $fonts {
.font-size-#{$font} {
font-size: $font-size-#{$font};
}
}
Made it this way. 这样做。 Its working fine with key value approach.
它的工作正常与关键价值方法。
$font-size-40: .5rem;
$font-size-50: .625rem;
$font-size-60: .75rem;
$fonts: (
'40': $font-size-40,
'50': $font-size-50,
'60': $font-size-60,
);
@each $font, $prop in $fonts {
.font-size-#{$font} {
font-size: #{$prop};
}
}
But still want to know why we cant use it like:- $font-size-#{$font} 但仍然想知道为什么我们不能使用它: - $ font-size - #{$ font}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.