翻译自: 英文原文链接
The following table summarizes the Selector syntax:
模式 | 含义 | 描述 | CSS Level |
---|---|---|---|
* | any element | universal selector | 2 |
E | an element of type E | Type selector | 1 |
E[foo] | an E element with a “foo” attribute | Attribute selector | 2 |
E[foo=”bar”] | an E element whose “foo” attribute value is equal to “bar” | Attribute selector | 2 |
E[foo~=”bar” | an E element whose “foo” attribute value is a list of whitespace-separated values, one of which is equal to “bar” | Attribute selector | 2 |
E[foo^=”bar”] | an E element whose “foo” attribute starts with “bar” | Attribute selector | 2 |
E[foo$=”bar”] | an E element whose “foo” attribute ends with “bar” | Attribute selector | 3 |
E[foo*=”bar”] | an E element whose “foo” attribute value contains the substring “bar” | Attribute selector | 3 |
E[foo | =”en”] | 匹配所有att属性具有多个连字号分隔(hyphen-separated)的值、其中一个值以“val”开头的E元素,主要用于lang属性,比如“en”、“en-us”、“en-gb”等等 | Attribute selector |
E:root | an E element, root of the document | Structural pseudo-classes | 3 |
E:nth-child(n) | an E element, the n-th child of its parent | Structural pseudo-classes | 3 |
E:nth-last-child(n) | an E element, the n-th child of its parent, counting from the last one | Structural pseudo-classes | 3 |