1.22 伪类

用来添加一些选择器的特殊效果;
元素的某种状态,用于选中该元素以设置效果;

举例

input:checked {
    // 选中的 input
}

input:disabled {
    // 禁用的 input
}

p:empty {
    // 没有子元素的 p
}

input:enabled {
    // 启用的 input
}

p:first-of-type {
    // 每个元素中的 第一个 p;含 嵌套
}


input:in-range {
    // 输入值在指定范围内的 input
}

input:invalid {
    // 不符合输入格式的(无效的) input
}

p:last-child {
    最后一个 p
}

p:last-of-type {
    // 每个元素中的 最后一个 p;含 嵌套
}

:not(p) {
    // p 以外的元素
}

p:nth-child(2) {
    // 第 2 个 p
}

p:nth-last-child(2) {
    // 倒数 第 2 个 p
}

p:nth-last-of-type(2) {
    // 倒数 第 2 个 子元素 p
}

p:nth-of-type(2) {
    // 第 2 个 子元素 p
}

p:only-of-type {
    // 仅有一个子元素 p 的 p 元素
}

p:only-child {
    // 仅有一个子元素 p 的元素的 父元素
}

input:optional {
    // 非 required 的 input
}

input:out-of-range {
    // 输入值 超出 指定范围内的 input
}

input:read-only {
    // 只读的 input
}

input:read-write {
    // 可 读写的 input
}

input:valid {
    // 有效的 input
}

a:link {
    // 未访问的 a
}

a:visited {
    // 已访问的 a
}

a:active {
    // 正在活动的 a
}

a:hover {
    // 鼠标悬停的 a
}

input:focus {
    // 焦点状态的 input
}

p:first-child {
    // 作为第一个子元素的 p
}

p:lang(it) {
    // lang == it 的 p
}