有没有办法将 nth-child
值用作 SASS 变量?
Is there any way to use the nth-child
value as a SASS variable ?
使用示例:
div:nth-child(n) {
content: '#{$n}'
}
div:nth-child(n) {
background: rgb(#{$n}, #{$n}, #{$n});
}
我不认为有办法做到这一点.但是你可以使用 @for
指令来循环已知数量的元素:
I don't think there's a way to do exactly that. But you can use @for
directive to loop through a known number of elements:
$elements: 15;
@for $i from 0 to $elements {
div:nth-child(#{$i + 1}) {
background: rgb($i, $i, $i);
}
}
这篇关于使用第 n 个子值作为 SASS 变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!