search

Home  >  Q&A  >  body text

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

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

伊谢尔伦伊谢尔伦2810 days ago947

reply all(1)I'll reply

  • 迷茫

    迷茫2017-04-17 11:24:29

    Pseudo class should be written as :weilei according to current specifications.
    Pseudo element should be written as ::weiyuansu

    according to current specifications.

    But when the specification was not clear in the past, pseudo-elements and pseudo-classes were written as: weiyuansu :weilei
    In order to be compatible with the past writing method
    , your pseudo-elements written in quotation marks can also be parsed

    The main pseudo elements are:
    E:first-letter/E::first-letter E:first-line/E::first-line E:before/E::before E:after/E:: after E::placeholder E::selection

    The main pseudo-classes are:
    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

    Single colon and double colon are mainly to distinguish between pseudo elements and pseudo classes

    The difference between the two Introduction to the Desert Illustration css3 p69

    Pseudo-classes generally reflect the state or attributes of an element that cannot be easily or reliably detected in CSS;
    Pseudo-elements represent some kind of document structure outside the DOM

    reply
    0
  • Cancelreply