-1

I have question about CSS selectors. I have below structure - I can only modiffy CSS - I don't have access to modify html or JS.

 <div class="wrapper">
  <div>
    <div>
      <div class="open">

      </div>
    </div>
  </div>
  <div>
    <div class="top">

    </div>
  </div>
</div>

Class open will be toggled. Can I make selector when:

  1. div in 4 line has open - div with class top => .top {top:50px}
  2. div in 4 line not has open - div with class top => .top{top:0px;}

This is possible?

JJanek
  • 99
  • 3

1 Answers1

-1

Try this:

.wrapper div:not(.open){
    ...
}

You will need to adjust it to the get the correct DIV, because this will affect all of them inside .wrapper

In your case it looks like you need something like:

.wrapper > div > div > div:not(...){...}

However, that is a bad practice.

You can read some more here: https://developer.mozilla.org/en-US/docs/Web/CSS/:not

Martin Chaov
  • 824
  • 7
  • 17