CSS:内容:“\00a0”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2770681/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CSS: content:"\00a0"
提问by SteD
Today I came across a new CSS syntax that I have never seen before
今天我遇到了一个我以前从未见过的新 CSS 语法
content:"#horz-list li {
list-style: none;
float: left;
}
#horz-list li:after {
content: "<ul id="horz-list">
<li>first item</li>
<li>second item</li>
<li>third item</li>
</ul>
a0-##代码##a0";
}
#horz-list li:last-child:after {
content: "";
}
a0";
Checking it on w3schools, it explains:
在w3schools上检查它,它解释说:
Definition and Usage
The content property is used with the :before and :after pseudo-elements, to insert generated content.
定义和用法
content 属性与 :before 和 :after 伪元素一起使用,以插入生成的内容。
My question is, can you point out to me in real world example, how do we use this contentproperty? And what does the \00a0mean in this case?
我的问题是,你能在现实世界的例子中向我指出,我们如何使用这个content属性?\00a0在这种情况下是什么意思?
采纳答案by Ben Rowe
I've used it before to implement styling text on a floated list
我以前用它在浮动列表上实现样式文本
That will produce something like
那会产生类似的东西
first item - second item - third item
第一项 - 第二项 - 第三项
This keeps my markup semantic & I can introduce styling such a the dash via css.
这保持了我的标记语义,我可以通过 css 引入样式,例如破折号。
回答by Sarfraz
The contentproperty is used to add content or even adding html entities. As for \00a0, it is hex code for a non-breaking space.
该content属性用于添加内容甚至添加 html 实体。至于\00a0,它是用于不间断空格的十六进制代码。
Resources:
资源:
More Information
Javascript, CSS, and (X)HTML entities in numeric order

