Is there any way to use the nth-child value as a SASS variable ?
nth-child
Examples of use :
div:nth-child(n) { content: '#{$n}' }
div:nth-child(n) { background: rgb(#{$n}, #{$n}, #{$n}); }
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:
@for
$elements: 15; @for $i from 0 to $elements { div:nth-child(#{$i + 1}) { background: rgb($i, $i, $i); } }
2.1m questions
2.1m answers
60 comments
57.0k users