css pseudo-class and the use of pseudo-class selector

Pseudo-elements are used to create some elements that do not exist in the original dom structure tree. For example, ::before, ::after add content to some existing elements, it will be displayed in specific UI, but these content will not appear in dom

Pseudo-class means that an existing element is in a certain state, but the style of different states cannot be expressed through the dom tree.

Insert picture description here

What are the pseudo-class selectors:

  • E: last-child selects the last child element of the parent element
  • EE: nth-child(n) selects the nth element of the parent element
  • E: nth-last-child(n) selects the last nth element E of the parent element, which must meet the nth last element and be the E tag, otherwise it is invalid
  • E: first-of-type selects the first element of the same label that meets the conditions
  • E: last-of-type selects the last element of the same tag that meets the conditions
  • E: nth-of-type(n) selects the nth element of the same label that meets the conditions

Guess you like

Origin blog.csdn.net/weixin_43956521/article/details/112554286