gpt4 book ai didi

css - 在 SCSS 中迭代列表数据类型

转载 作者:太空宇宙 更新时间:2023-11-04 06:35:54 25 4
gpt4 key购买 nike

我发现这很有趣 SCSS advanced guide ,有很多很酷的使用方法。然后我卡在了下面那个,迭代器很清楚,但是我不明白数字 1 和数字 2 是干什么用的。有什么想法吗??

SCSS

$buttonConfig: 'save' 50px, 'cancel' 50px, 'help' 100px; 

@each $tuple in $buttonConfig {
.button-#{nth($tuple, 1)} {
width: nth($tuple, 2);
}
}

编译的 CSS

.button-save {
width: 50px;
}
.button-cancel {
width: 50px;
}
.button-help {
width: 100px;
}

最佳答案

nth($list, $index):返回$list中$index位置的值所以在最后一个例子中,$buttonConfig: '保存' 50px, '取消' 50px, '帮助' 100px;$tuple 在第一次迭代中将“保存”50,因此 ($tuple, 1) 将保存并且 ($tuple, 2) 将是宽度值 50px 等等。

关于css - 在 SCSS 中迭代列表数据类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54233236/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com