nth-child-when-sibling-changes.html (899B)
1 <!DOCTYPE html> 2 <meta charset="utf-8" /> 3 <title>CSS Selectors Invalidation: :nth-child(... of class) when sibling changes</title> 4 <link rel="author" title="Steinar H. Gunderson" href="sesse@chromium.org"> 5 <link rel="match" href="nth-child-when-sibling-changes-ref.html"> 6 <link rel="help" href="https://drafts.csswg.org/selectors-4/#child-index"> 7 <style> 8 .sibling + :nth-child(odd of .c) { 9 color: green; 10 } 11 </style> 12 <div> 13 <p class="sibling" id="toggler">Ignored</p> 14 <p class="c">Odd; used to be green, should not be since no sibling</p> 15 <p class="c">Even, so should not be green</p> 16 <p class="c" class="sibling">Odd, but no sibling, so should not be green</p> 17 <p class="c">Even, so should not be green</p> 18 <p class="sibling">Ignored</p> 19 <p class="c">Odd, should be green</p> 20 </div> 21 <script> 22 document.documentElement.offsetTop; 23 toggler.classList.toggle("sibling"); 24 </script>