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