もちろん、コードはさらに複雑化しますが両者を組み合わせることもで
きます。例えば項目数が 2 個から 6 個までのリストを対象にするには、以
下のようにします。
▶ PLAY!
play.csssecrets.io/styling‐sibling‐count
li:first‐child:nth‐last‐child(n+2):nth‐last‐child(‐n+6),
li:first‐child:nth‐last‐child(n+2):nth‐last‐child(‐n+6)~
li{
/*項目数が2つ以上6つ以下のリストで、各項目に適用される
スタイル*/
}
関連仕様
Selectors
w3.org/TR/selectors