css:before和:after伪元素的内容属性

css:before和:after伪元素的内容属性

问题描述:

我试图理解为什么只有当内容属性被定义(与或任何其他文本但定义)只有我可以应用其他CSS属性,例如如果我删除内容属性它就像没有元素,没有其他css属性适用,我会猜测内容属性是 构造函数 元素(:before或:after),在此链接 i将引用:

I was trying to understand why only when content property is defined (with "" or any other text but defined) only than i can apply other css properties, For example if i remove the content property it's like there is no element and there is no other css properties apply, I would guess the content property is the "constructor" of the pseudo-element (:before or :after), At this Link i will quote:


使用content属性插入的对象

Objects inserted using the content property

对象是我理解的:before或:after 伪元素,

插入(创建)

最后我的问题:虽然我说到现在为止,帮助我更好的解释比我写我会非常感谢,谢谢大家,有一个美好的一天。

Finally my question: Although all i said until now, am i right?, If anyone can help me with better explanation than i wrote i will be very thankful, Thank you all and have a nice day.

content 的初始值为 none 当不定义 content 时,使用该值,当使用该值时,伪元素根本不生成。空字符串 none 不同;空字符串表示插入一个空对象,而 none 表示不要插入任何东西。

The initial value of content is none. When you don't define content, that value is used, and when that value is used, the pseudo-element is simply not generated at all. An empty string "" is not the same as none; the empty string means "insert an empty object", whereas none means "don't insert anything at all".

确实,说对象插入基本上与伪元素创建或框渲染等相同。

Indeed, saying "objects inserted" is basically the same as "pseudo-elements created" or "boxes rendered", etc.