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