Why is it impossible to change content in css?

前端 未结 3 653
猫巷女王i
猫巷女王i 2021-01-13 14:41

CSS2.1 pseudo-selectors such as ::after and ::before allows to add text content to the page. For example :

CSS



        
3条回答
  •  离开以前
    2021-01-13 15:17

    The CSS 2.1 spec cited says: “Applies to: :before and :after pseudo-elements”. This restriction has been relaxed in the draft for CSS3 Generated and Replaced Content Module, which is old (2003) and outdated but still partly implemented. Opera seems to support content for normal elements, except for the use of URL values (used to insert images), whereas Chrome and Safari do the same only for URL values. So you code actually works on Safari.

    More widespread support is not very likely unless specification work on the module makes some progress. On the W3C CSS module status page, the module is in the “Rewriting” section, with the note “Severely outdated”.

提交回复
热议问题