DEV Community

Discussion on: Style parent element if child a specific class

dry profile image
Hayden Mankin

As far as I know there is no way to do this with SCSS, as there is no way to do it with CSS that it will compile to.

There is a draft for this feature, so we may see it in the future.

You can, however, achieve this using JQuery

$(".four").parent(".parent").css("padding", "0px");
mikacaldera profile image
Mika Caldera Author • Edited on

Thanks so much!
For both the link to the upcoming feature and the alternate solution.

I'll give the alternate js solution a try.

I gave it a try. Only edit was to change parent to parents. It didn't seem to work otherwise.

// Removes padding when portal is present
   $('.portal-group').parents('.cover').css('padding-bottom', '0px');