Why is it impossible to change content in css?

前端 未结 3 654
猫巷女王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:10

    Actually it is possible to use content property directly on elements, and not on pseudo-elements only. Try

       p { content:'My hero is' }
    

    in Opera and you'll see the result you wanted. The thing is other browsers don't support it yet.

    A lot of other interesting things concerning generated content cat be found in CSS3 Generated and Replaced Content Module, but we'll have to wait a bit until browser venrors implement it.

提交回复
热议问题