Tuesday, July 23, 2024
HomeJavaScriptThe CSS amount question with :nth-last-child()

The CSS amount question with :nth-last-child()


Revealed at

Up to date at

Studying time
1min

Simply parking this CSS snippet on my weblog for my future self. 🙈

If you wish to choose parts solely when there is a given variety of them, you possibly can use a :nth-last-child() selector mixture.

The next selector mixture is named a “amount question”.

li:nth-last-child(n+3),
li:nth-last-child(3) ~ li {
  coloration: crimson;
}

See it in motion beneath. 👇

Preview

Associated Subjects

Associated Articles



RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments