相关疑难解决方法(0)

关联数组SCSS/SASS

我需要将数字转换为单词,所以:

  • "1-3" - >"三分之一"
  • "3-3" - >"三分之三"
  • "2-5" - >"五分之二"

这些数字是在一个循环中产生的,它应输出一群不同的类名等的one-thirdone-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
    }
}
Run Code Online (Sandbox Code Playgroud)

我想我需要使用两个不同的关联数组,在PHP中(仅作为示例)可能看起来像:

$1 = array( 
   "1"=>"one", 
   "2"=>"two", 
   "3"=>"three" 
);

$2 = array( 
   "1"=>"whole", 
   "2"=>"half", 
   "3"=>"third" 
);
Run Code Online (Sandbox Code Playgroud)

是否可以在SASS/SCSS中创建关联数组或是否有任何解决方法?

arrays sass

33
推荐指数
2
解决办法
3万
查看次数

标签 统计

arrays ×1

sass ×1