-1

lets have this selector

.A ~ .A .B{
  padding-top: 0;
}

I understand that this will put padding-top: 0 when at least two elements use class A together with B

now lets assume that there are indeed two elements but one has also display: none

<div class="A">
    <div class="B"><div> //do not apply this since second div with A is disabled
<div>
<div class="A" style="display:none"><div>

in this way how to modify this selector not be applicable since on UI it looks like there just one div.

TylerH
  • 20,799
  • 66
  • 75
  • 101
kosnkov
  • 5,609
  • 13
  • 66
  • 107

1 Answers1

2

No, selector .A ~ .A .B means

.A ~ .A .B {color: red;}
<div class="A">First element</div>
<div class="A">
    <div class="B">This element will be targeted</div>
</div>

Selector, you are looking for is

.A ~ .A.B {color: red}
<div class="A">First element</div>
<div class="A">
    <div class="B">This element will not be targeted</div>
</div>
<div class="A B">This element will be targeted</div>

Which means sibling of .A element and has classes at least class="A B".

pavel
  • 26,538
  • 10
  • 45
  • 61