我需要将数字转换为单词:
- "1-3" -> "one-third"
- "3-3" -> "three-thirds"
- "2-5" -> "two-fifths"
这些数字是在循环中生成的,应该输出一堆不同的类名,如one-third
或one-half
:
$number = 3;
@for $i from 1 through $number-1 {
// some calculations to output those classes: ".one-third", ".two-thirds"
// The following currently outputs class names like ".1-3" and ".2-3"
.#{$i}-#{$number} {
// CSS styles
}
}
我认为我需要使用两个不同的关联数组,在 PHP 中(仅举例)可能如下所示:
$1 = array(
"1"=>"one",
"2"=>"two",
"3"=>"three"
);
$2 = array(
"1"=>"whole",
"2"=>"half",
"3"=>"third"
);
在SASS/SCSS中是否有可能创建关联数组,或者是否有任何解决方法?