关联数组SCSS/SASS

 v56158645 发布于 2023-01-31 14:38

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

"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
    }
}

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

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

$2 = array( 
   "1"=>"whole", 
   "2"=>"half", 
   "3"=>"third" 
);

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

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有