Selector:first-child This is the descendant selector. Weird, be careful to avoid rather than understand.
Selector:first-child
The first element in the current selector selected element collection
Selector:last-child
The last element in the collection of currently selector selected elements.
However, there is a problem: Last-child does not take effect.
Should be:
1 parent element of current Selector
2 Parent all child elements, [a,b,c]
3 The first element of a collection of child elements, if it is selector
4 set the style to take effect.
**if (selecor.parent.childElementList.firstElement = = = Selector) { effective }**
So use these two pseudo-classes to add a parent element on it. It can be thought of as the first realization.
Nth-child () also applies to the above rules.
Note that n here has a lot of room for development, you can achieve odd/even, choose which few, from which to choose.
Nth-last-child () reverse the selection
: First-of-type
: Last-of-type
: Nth-of-type
: Nth-last-of-type
: Root
Select the document root element. It's HTML.
: Empty
Select an element that has no spaces in the element
: not
Negative Selector
: Only-child
It only takes effect when the collection has only one element.
:: Selection
Only two properties can be set: Background,color.
Selector:first-child This is the descendant selector. Weird, be careful to avoid rather than understand.
Selector:first-child
The first element in the current selector selected element collection
Selector:last-child
The last element in the collection of currently selector selected elements.
However, there is a problem: Last-child does not take effect.
Should be:
1 parent element of current Selector
2 Parent all child elements, [a,b,c]
3 The first element of a collection of child elements, if it is selector
4 set the style to take effect.
**if (selecor.parent.childElementList.firstElement = = = Selector) { effective }**
So use these two pseudo-classes to add a parent element on it. It can be thought of as the first realization.
Nth-child () also applies to the above rules.
Note that n here has a lot of room for development, you can achieve odd/even, choose which few, from which to choose.
Nth-last-child () reverse the selection
: First-of-type
: Last-of-type
: Nth-of-type
: Nth-last-of-type
: Root
Select the document root element. It's HTML.
: Empty
Select an element that has no spaces in the element
: not
Negative Selector
: Only-child
It only takes effect when the collection has only one element.
:: Selection
Only two properties can be set: Background,color.