Targeting First 2 Children Or Last 2 Children
I know a bunch of the pseudo classes (first-child, last-child, nth-child) but I am having trouble selecting the first 2 children in a list or the last 2, the list is dynamic and ch
Solution 1:
For the first two children you can use:
ul li:nth-child(-n + 2) {
color: orange;
}
For the last two:
ul li:nth-last-child(-n + 2) {
color: orange;
}
Post a Comment for "Targeting First 2 Children Or Last 2 Children"