Home  >  Article  >  Web Front-end  >  The similarities and differences between :before and ::before

The similarities and differences between :before and ::before

零下一度
零下一度Original
2017-06-24 11:28:071755browse
  • Same points

    1. can be used to represent pseudo-class objects, used to set The content before the object

    2. :before and ::before writing are equivalent

  • Differences

    1. ##:before is the writing method of Css2, ::before is the writing method of Css3

    2. :before has better compatibility than ::before, but it is recommended to use ::before in H5 development

Notes:

Pseudo-class objects should be used together with the content attribute

Pseudo-class objects will not appear in the DOM, so they cannot be operated through js. They are only added to the CSS rendering layer

Pseudo-class objects Special effects usually use the :hover pseudo-class style to activate



##.test:hover:: before {
/* This is when animation and transition take effect */ }

The above is the detailed content of The similarities and differences between :before and ::before. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn