CSS to apply if 2 elements exist
问题 Given the following HTML markup, I want to apply (S)CSS only when 2 of the same elements exist (not when 1 exists). I don't want to use JavaScript to count the number of elements and apply another class, however, I feel this is the only approach. div { a + a { // I want to apply styles to both a tags, not just the second one // WHEN 2 a tags exists } } <div> <a href="/">Home</a> <a href="/about">About</a> </a> 回答1: You can use "quantity queries". For exactly TWO... a:nth-last-child(n+2):nth