LoginSignup
9
8

More than 5 years have passed since last update.

CSSだけで○番目以降の要素にだけ擬似クラス、疑似要素を適用する

Last updated at Posted at 2016-10-06

既出な上にあんまり使う機会はないかもしれないけど一応メモ。

li:nth-child(n + 3):last-child {
    color: #FF0000;
}

無題.png

こんな感じになります。
nth-child(-n + 3)とかにすると3個以下の場合に適用させることが出来ます。
::afterとかの疑似要素や、他の擬似クラスもどんどん追加できるのでCSSだけで割と多くのことが出来ますね。

9
8
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
9
8