首页 > css中伪类选择器跟伪对象选择器区别是啥

css中伪类选择器跟伪对象选择器区别是啥

我试过例如:p::first-letter 跟 p:first-letter 设置一段文字一个字的字体;两种方法 效果一模一样啊~!那么伪类选择器跟伪对象选择器区别是啥???


伪类 按现在的规范应当书写成 :weilei
伪元素 按现在的规范 应当书写成 ::weiyuansu

但是 以前规范不明确的时候 伪元素 和 伪类 都是写成 :weiyuansu :weilei
为了兼容过去的写法
所以 你的伪元素 写成一个引号的形式 也是可以被解析的

伪元素主要有:
E:first-letter/E::first-letter E:first-line/E::first-line E:before/E::before E:after/E::after E::placeholder E::selection

伪类主要有:
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 @page:first @page:left @page:right

单冒号 双冒号 主要是为了区别 伪元素还是伪类

两者的区别 引子 大漠 图解css3 p69

伪类一般反映无法在CSS中轻松或者可靠检测到的某个元素的状态或者属性;
伪元素表示DOM外部的某种文档结构

【热门文章】
【热门文章】