【发布时间】:2014-02-16 04:02:32
【问题描述】:
我需要将数字转换成单词,所以:
- “1-3”->“三分之一”
- “3-3”->“三分之三”
- “2-5”->“五分之二”
数字是在循环中生成的,它应该输出一堆不同的类名,如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 中创建关联数组,或者是否有任何解决方法?
【问题讨论】:
-
即将发布的 Sass 版本 - v3.3 - 引入了地图,可以像关联数组一样使用:github.com/nex3/sass/blob/master/doc-src/…