3
4

【CSS】子要素が特定の数の場合にのみスタイルを適用する方法

Posted at

以下のように記述すると子要素が指定した数の場合にのみスタイルを適用できます。

ul:has(> :nth-child(N):last-child) li {  }

子要素が2つの場合にのみスタイルを適用するには以下のように記述します。

ul:has(> :nth-child(2):last-child) li {  }
3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4