It seems that achieving what you want solely through the provided markup is not possible.
Within your template, there may be a condition set for the class C
.
You might consider adding a condition to include an additional class to the class A
element when the condition for class C
is met.
If class C
is not displayed, your structure would look like this:
<div class='A'>
...
</div='A'>
However, if class C
is displayed, your structure would resemble:
<div class='A contains-c'>
<div class='B' />
<div class='C' />
</div='A'>
<div class='D' />
Subsequently, you can utilize the following CSS:
.contains-c + .D {
...
}
A has()
CSS pseudo-class is in development, but its support is currently limited. You can explore more about it here if you're interested.