Closed ikh00000 closed 3 years ago
The correct syntax:
@define-mixin mixinName $containerName, $number: 12 {
:global(.desktop){
& .$(containerName) > div:nth-child(30n + 22 + $number) {
/* some code */
}
}
}
@mixin mixinName container1, 9;
But it will generate :nth-child(30n + 22 + 9)
, which is not correct nth-child
syntax.
Solutions:
+ 22
and use 31
in @mixin mixinName container1, 31
.selector: & .${containerName} > div:nth-child(30n + ${number + 22})
https://github.com/postcss/postcss-mixins#function-mixin@ai Many thanks, the second solution looks pergect for me, but unfortunately doesn't works, may be because of project dependencies troubles. The first one works good
I have some troubles with passing $number to nth-child expression in mixin. For now it works good if I delete calculations inside nth-child and leave just div:nth-child($number) . Would be thankful for helping to resolve it.