css选择器

174 阅读1分钟

类选择器.box 元素选择器 div ID选择器 #box 派生选择器 div.box div#box.box 属性选择器 [title="容器"] *= 值包含什么 ^= 以什么开头 $= 以什么结尾 结构伪类选择器 a:first-of-type

a:nth-of-type()
括号后面:
n + 4 从第四个开始一直往后所有的
2n + 1 奇数
2n 偶数
odd 奇数
even 偶数
n + 3 前三个
:nth-of-type(-n + 9):nth-of-type(n + 4) 从第四个到第九个
a:last-of-type
:nth-last-of-type


css2.0

    div:first-child div的第一个子节点
    div:last-child div的最后一个子节点
    div:nth-child div的第n个子节点

:not()除了 :empty()空元素 :target 激活元素、当前元素 :checked 选中项 :not(:checked) 未选中项 :disabled 禁用项 :not(:disabled) === :enable 可选项 :focus 获得焦点 ::selection 选中的文本选择器 加号:后边一个兄弟选择器 ~ 后边所有兄弟选择器 :first-letter 第一个文本