Hello Universe Hello Universe - 3 months ago 206
Sass (Sass) Question

How to reference grandparent in scss?

I have a scss question.

Lets say I have something like this

.footer-logos {


&__link {


&:nth-child(2) a{
}

&:nth-child(3) a {
}

&:nth-child(4) a {
}
}

&__imagelink {
}
}


As you can see, I have &:nth-child(n) a. I want this to be like a has the class .footer-logos__imagelink. I tried to do like below

&:nth-child &__imagelink


Obviously, that did not work. I wonder how I can reference it there?

Answer

Goal: .footer-logos__imagelink

& gives the parent's full selector, to achieve your goal you need to concatenate it with the child, to do so we can use string interpolations!

.footer-logos {
  #{&}__imagelink {

  }
}
Comments