I am trying to transpile this scss to css
input
JavaScript
x
23
23
1
.abc{
2
.slider {
3
$root: &;
4
&--fade {
5
> #{$root}__track {
6
> #{$root}__list {
7
> #{$root}__slide {
8
.rh08w5 {
9
opacity: 0;
10
h2 {
11
opacity: 0;
12
}
13
14
15
}
16
17
}
18
}
19
}
20
}
21
}
22
}
23
output
JavaScript
1
7
1
.abc .slider--fade > .abc .slider__track > .abc .slider__list > .abc .slider__slide .rh08w5 {
2
opacity: 0;
3
}
4
.abc .slider--fade > .abc .slider__track > .abc .slider__list > .abc .slider__slide .rh08w5 h2 {
5
opacity: 0;
6
}
7
expected output
JavaScript
1
7
1
.abc .slider--fade > .slider__track > .slider__list > .slider__slide .rh08w5 {
2
opacity: 0;
3
}
4
.abc .slider--fade > .slider__track > .slider__list > .slider__slide .rh08w5 h2 {
5
opacity: 0;
6
}
7
In my output .abc
class added in all item . I want it should add only on top element ?
how to remove .abc
class from child element
Advertisement
Answer
It’s not possible using the parent selector. The only way I can think of is to store the .slider
class in your root variable instead:
JavaScript
1
21
21
1
.abc {
2
$root: ".slider";
3
4
#{$root} {
5
&--fade {
6
> #{$root}__track {
7
> #{$root}__list {
8
> #{$root}__slide {
9
.rh08w5 {
10
opacity: 0;
11
h2 {
12
opacity: 0;
13
}
14
}
15
}
16
}
17
}
18
}
19
}
20
}
21