0

given the following structure, is there a way to select sibling-b using less?

<div class='sibling-a'>
    <div class='only-if-this-class-is-present'
</div>
<div class='sibling-b'>
</div>

As you may gather, I would like to select sibling-b whenever only-if-this-class-is-present exists on sibling-a's descendant element.

I know CSS does not have a parent selector, and I've looked at answers to questions such as...

Is there a CSS parent selector?

Selector for subsequent sibling of element containing specific item

... but I'm curious to know if I can select elements this way using Less?

Thank you!

hcs
  • 321
  • 3
  • 14
  • 1
    You need to use JavaScript. Less is just CSS. – Diodeus - James MacFarlane Jun 04 '19 at 15:36
  • Hum, I suspected as much, thank you @Diodeus-JamesMacFarlane – hcs Jun 04 '19 at 15:39
  • 1
    For what its worth, CSS Level 4 draft is trying to get `:has()` pseudo-selector (similar to jQuery's), but no browsers have implemented it yet. https://drafts.csswg.org/selectors-4/#relational Maybe in the future it can be done with just CSS, but for now you'll have to use JavaScript. – jeffjenx Jun 04 '19 at 15:41

0 Answers0