I want to nest selector for <a>
tag inside a class .class-name
, in order to apply those styles only for elements who has both the <a>
tag and the class .class-name
using SCSS. What I want to do can be performed the following way:
.class-name {
font-size: 40px;
}
a.class-name {
color: #ff6666;
}
<div class="class-name">Hello</div>
<a class="class-name" href="#">World!</a>
I've tried two different ways in SCSS using &
parent selector
# successfully transpiled but no change
.class-name {
font-size: 40px;
&a {
color: #ff6666;
}
}
# Got an error trying to transpile
.class-name {
font-size: 40px;
a& {
color: #ff6666;
}
}
I do not want to nest the other way around (.class-name
inside a
).