Home >Web Front-end >HTML Tutorial >The 10 Most Misunderstood CSS Selectors_html/css_WEB-ITnose

The 10 Most Misunderstood CSS Selectors_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:57:291234browse

These selectors include first-child, last-child, only-child, nth-child(n), nth-last-child(n) and first-of-type, last-of-type, only-of-type, nth-of-type(n), nth-last-of-type(n). Of all the selectors, these ten are probably the most misunderstood.


1. Regarding n

1) The expression of n is: xn y. Such as 1, 2n, 2n 1.

2) n in the nth-child(n) series numbers all child elements of the parent element; n in nth-type-child(n) only numbers elements of the same type, ignoring the middle ones Incorporated other elements.


2. E:first-child and E:first-child

The above two ways of writing are different. There is a big difference between whether there is a space before :first-child and whether there is a space. This is also the most misunderstood part.

1) E:first-child without spaces means "select such an E element, which is the first child element of its parent element";

2) E with spaces :first-child means "select the first child element of the E element".

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn