CSS3 :nth-last-child() Selector
Specify a foundation shading for each <p> component that is the second offspring of its parent, checking from the last child:
More "Attempt it Yourself" models below.
Definition and Usage
The :nth-last-child(n) selector coordinates each component that is the nth youngster, paying little mind to type, of its parent, tallying from the last child.
n can be a number, a watchword, or a formula.
Tip: Look at the :nth-last-of-type() selector to choose the component that is the nth child, of a predetermined type, of its parent, tallying from the last child.
The numbers in the table indicates the primary program form that completely underpins the selector.
Odd and even are keywords that can be used to match child elements whose index is odd or even.
Here, we specify two different background colors for odd and even p elements, counting from the last child:
Using a formula (an + b). Description: a represents a cycle size, n is a counter (starts at 0), and b is an offset value.
Here, we specify a background color for all p elements whose index is a multiple of 3, counting from the last child: