0

Is there a way to get the parent of a child element in SCSS?

html

<div>
    <span>test1</span>
</div
<div>
    <p>dsdfds</p>
</div>

In the above example how can I style only the parent of an span element?

Davide Casiraghi
  • 15,591
  • 9
  • 34
  • 56
Pranab V V
  • 1,386
  • 5
  • 27
  • 53
  • See https://stackoverflow.com/questions/1014861/is-there-a-css-parent-selector – GoGoris Mar 06 '19 at 14:27
  • 2
    Possible duplicate of [Is there a CSS parent selector?](https://stackoverflow.com/questions/1014861/is-there-a-css-parent-selector) – GoGoris Mar 06 '19 at 14:27
  • If you're using jQuery, you could use `$(".parent > .child").parent().css("");`. – pjones235 Mar 06 '19 at 21:17
  • SCSS can't do anything that CSS can't. Until browsers start supporting [`:has`](https://caniuse.com/#feat=css-has), there is no way for SCSS/CSS to select parent elements. – mfluehr Mar 07 '19 at 14:08

0 Answers0