CSS nth child Selectors

Описание к видео CSS nth child Selectors

When you are trying to target HTML elements in a pattern, like every second or third list item or table row, then the nth-child selector and its partners are exactly what you need.

Remember that, unlike JavaScript, the HTML elements are numbered starting at one, not zero.

The formula used by these selectors is (an + b)
Where the letter `n` stays as n.
The letter a is replaced by a numeric multiplier.
The letter b is replace by a number which is the starting point.

The letter a can also be a negative integer.
Eg:
:nth-child(-2n + 4)
This would represent the following elements:
(-2 * 0 + 4) == 4
(-2 * 1 + 4) == 2
(-2 * 2 + 4) == 0 - no match for this or any numbers after this.


Code GIST: https://gist.github.com/prof3ssorSt3v...

Комментарии

Информация по комментариям в разработке