Reputation: 1024
Here is my scss
code-
$perc:100%;
@mixin childAlign($nb,$al){
td:nth-child($nb){
text-align:$al;
}
}
table,th,td{
border: 1px solid black;
}
img {
max-width: $perc;
max-height: $perc;
}
@include childAlign(1,center);
@include childAlign(2,left);
@include childAlign(3,left);
@include childAlign(4,center);
When I try to compile the code its showing error like
Error: Invalid CSS after "td:nth-child(": expected An+B expression, was "$nb)" on line 4 of C:\Users\ACTECH\Documents\q6\q6.scss, in `childAlign' from line 16 of C:\Users\ACTECH\Documents\q6\q6.scss
But is there any syntactical error?
Upvotes: 0
Views: 109
Reputation: 3289
You are using a variable inside a selector, so it has to be interpolated as follow #{$varName}
.
td:nth-child(#{$nb}) { ... }
Upvotes: 3