伪元素和伪类之所以这么容易混淆,是因为他们的效果类似而且写法相仿,但实际上 css3 为了区分两者,已经明确规定了伪类用一个冒号来表示,而伪元素则用两个冒号来表示。
1.伪元素
伪元素主要有:
e:first-letter/e::first-letter
e:first-line/e::first-line
e:before/e::before
e:after/e::after
e::placeholder
e::selection
2.伪类
伪类主要有:e:link
e:visited
e:hover
e:active
e:focus
e:lang(fr)
e:not(s)
e:root
e:first-child
e:last-child
e:only-child
e:nth-child(n)
e:nth-last-child(n)
e:first-of-type
e:last-of-type
e:only-of-type
e:nth-of-type(n)
e:nth-last-of-type(n)
e:empty
e:checked
e:enabled
e:disabled
e:target
input{//表单元素
:focus => 匹配已聚焦点的表单元素
:enabled => 匹配已经启用的表单元素(默认)
:disabled => 匹配禁用的表单元素
:checked => 匹配被选中的表单元素
}
我还以为只有lvha和before.after才是,想到这个家族这么庞大,又长见识了,当然秃头也同时contiune