css3选择器

  1. [attribute]; [target] 选择带有 target 属性所有元素。

  2. [attribute=value]; [target=_blank] 选择 target=”_blank” 的所有元素。

  3. [attribute=value]; [title=flower] 选择 title 属性包含单词 “flower” 的所有元素。(class=”flower red”)(title= ”flower red”)

  4. element1~element2 p~ul 选择前面有 p 元素(同胞,可以不相邻)的每个 ul 元素。(~选择有相同属性的所有元素)

  5. [attribute^=value] a[src^=”https”] 选择其 src 属性值以 “https” 开头的每个 a 元素。

  6. [attributecss3选择器 - 图1=”.pdf”] 选择其 src 属性以 “.pdf” 结尾的所有 a元素。

  7. :first-child p:first-child 选择属于父元素的第一个子元素p 元素。

  8. :first-of-typep:first-of-type 选择属于其父元素的首个 p 元素。

  9. :last-of-type p:last-of-type 选择属于其父元素的最后 一个子元素p 元素。

  10. :only-of-type p:only-of-type 选择属于其父元素唯一的 p 元素。

  11. :only-child p:only-child 选择属于其父元素的唯一子元素p元素。

  12. :nth-child(n) p:nth-child(2n+1) 选择属于其父元素的第奇数个子元素 元素。

  13. :nth-last-child(n) p:nth-last-child(2) 同上,从最后一个子元素开始计数。

  14. :nth-of-type(n) p:nth-of-type(2) 选择属于其父元素第二个 p元素。

  15. :nth-last-of-type(n) p:nth-last-of-type(2) 同上,但是从最后一个子元素开始计数。

  16. :last-child p:last-child选择属于其父元素最后一个子元素 p 元素。

  17. :first-letter p:first-letter 选择每个 p 元素的首字母。

  18. :first-line p:first-line 选择每个 p元素的首行。(加边框不行,字号可以)

  19. :before (伪元素) p:before 在每个p 元素的内容之前插入内容。

  20. :after(伪元素) p:after 在每个 p元素的内容之后插入内容。

  • :root 选择文档的根元素。(demo: width:100%)
  • 标签:empty 选择没有子元素的每个标签 元素(包括文本节点)。
  • 标签:target 选择当前活动的 标签 元素。(锚链接中单击链接跳转到的当前目标)
  • 标签:enabled 选择每个启用的 标签 元素。
  • 标签:disabled 选择每个禁用的 标签 元素
  • 标签:checked 选择每个被选中的 标签 元素。
  • :not(标签) 选择非(标签)元素的每个元素。
  • ::selection 选择被用户选取的元素部分。