:before && :after pseudo elements not showing Firefox

前端 未结 2 1897
甜味超标
甜味超标 2021-01-04 09:15

Firefox is not displaying :after and :before but they do show in Chrome.

Firefox & Chrome:

Viewing the source directly in Firefox shows the CSS is there

2条回答
  •  失恋的感觉
    2021-01-04 09:47

    You cannot use ::after and ::before on elements that cannot have content, such as .

    ::after and ::before work like this:

    
      ::before
      ***content***
      ::after
    
    ***content***
    

    They get inserted before and after the content of a DOM node. Since cannot have content, there's nowhere to put it.

    Now let's check with a checkbox:

    
    ***content***
    

    Here, there cannot be ***content*** to surround with pseudo elements.

提交回复
热议问题