0
0

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

Last updated at Posted at 2024-02-26

以下のように記述すると指定した数以下の場合にのみスタイルが適用されます。

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

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

ul:has(> :nth-child(-n+3):last-child) li { ... }
0
0
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
0
0