0

Example:

 <div class="wrap">
    <div class="ruin">
        <span class="nest">hello</span>
        <span class="nest">bye</span>
    </div>

    <div class="select">select from nest span</div>
 </div>

CSS

.nest ~ .select {
  color: red;
}

.wall .nest ~ .select {
  color: green;
}

I dont know how to select .select from .nest. Its not a sibling of it, or a child, or a parent.

Heres a jsfiddle. https://jsfiddle.net/cugok7v0/

EDIT: Ok it is not possible with just css to select elements without a logical relationship between them. This answer here which I didnt find myself says it all.

Thankfully I found a good way to not need to nest the element and so I can use adjacent sibling selector.

o0o0o0o0o
  • 89
  • 1
  • 11

0 Answers0