gpt4 book ai didi

variables - 创建 Sass mixin 时,我可以使用 :nth-child declaration? 中的变量吗

转载 作者:行者123 更新时间:2023-12-02 05:32:57 25 4
gpt4 key购买 nike

这是我写的 mixin(.scss 格式),但我收到了这个错误:

Invalid CSS after "($x) ": expected expression (e.g. 1px, bold), was "{"

@mixin x_cards_wide($x) {
.card {
&:nth-child(-n + $x) { margin-top: 0; }
&:nth-child($x * n) { margin-right: 0; }
}
}

查看CodePen

最佳答案

您可以使用 interpolations 完成此操作:

@mixin x_cards_wide($x) {
.card {
&:nth-child(-n+#{$x}) { margin-top: 0; }
&:nth-child(#{$x}n) { margin-right: 0; }
}
}

关于variables - 创建 Sass mixin 时,我可以使用 :nth-child declaration? 中的变量吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12128354/

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