Open LLwanran opened 5 years ago
::before 就是以一个子元素的存在,定义在元素主体内容之前的一个伪元素。并不存在于dom之中,只存在于页面之中 :before 和 :after 这两个伪元素,是在 CSS2.1 里新出现的。起初,伪元素的前缀使用的是单冒号语法,但随着Web的进化,在CSS3的规范里,伪元素的语法被修改成使用双冒号,成为 ::before ::after
::before
:before
:after
CSS2.1
::after
常见伪元素:::before,::after,::first-line,::first-letter,::selection、::placeholder 常见伪类::hover,:link,:active,:target,:not(),:focus
常见伪元素:::before,::after,::first-line,::first-letter,::selection、::placeholder
::first-line
::first-letter
::selection
::placeholder
常见伪类::hover,:link,:active,:target,:not(),:focus
:hover
:link
:active
:target
:not()
:focus
单冒号(:)用于CSS3伪类
双冒号(::)用于CSS3伪元素
::before
就是以一个子元素的存在,定义在元素主体内容之前的一个伪元素。并不存在于dom之中,只存在于页面之中:before
和:after
这两个伪元素,是在CSS2.1
里新出现的。起初,伪元素的前缀使用的是单冒号语法,但随着Web的进化,在CSS3的规范里,伪元素的语法被修改成使用双冒号,成为::before
::after
标准写法是双冒号(但考虑兼容性也有人写单冒号)