在每个 mixin 中使用变量数组
我很难弄清楚如何为“each”语句中使用的变量编写数组。
$array: (("1", "../../Media/Images/FirstImage.png"), ("2", "../../Media/Images/SecondImage.png"));
@each $i in $array {
&:nth-child( #{$i} ) {
a {
&:before {
content: "";
background: url({This is the 2nd part of each variable}) no-repeat;
}
}
}
}
I'm having a hard time trying to figure out how to write an array for a variable to be used in an "each" statement.
$array: (("1", "../../Media/Images/FirstImage.png"), ("2", "../../Media/Images/SecondImage.png"));
@each $i in $array {
&:nth-child( #{$i} ) {
a {
&:before {
content: "";
background: url({This is the 2nd part of each variable}) no-repeat;
}
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您当前有一个数组的数组,而不是变量或值的一维数组。看来您可以将数组更改为一维数组,然后仅使用
:nth-child()
的索引。You currently have an array of arrays, not a single-dimensional array of variables or values. It seems like you could change your array to be 1-dimensional, and just use the index for the
:nth-child()
.