CSS 内容的作用是什么:“\0020”;财产?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11540728/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 04:32:14  来源:igfitidea点击:

What is the effect of content: "\0020"; property?

css

提问by zarpio

.container:after {
content: "##代码##20";
display: block;
height: 0;
clear: both;
visibility: hidden;
overflow:hidden;}
内容

Please explain what is the effect of "content: "\0020"; property?

请解释一下"content:"\0020";属性的作用是什么?

回答by Konrad Rudolph

\0020inserts the Unicode code point U+0020, which is a space. So the code is equivalent to content: ' ';.

\0020插入 Unicode 代码点 U+0020,这是一个空格。所以代码等价于content: ' ';.

content: xreplaces the content (= the displayed text) with the value x.

content: x用值替换内容(= 显示的文本)x

However, in the snippet you've posted, this content is made invisible anyway so you won't actually see anything. The code is a clearfiximplementation to re-float elements on the page.

但是,在您发布的代码段中,该内容无论如何都是不可见的,因此您实际上看不到任何内容。该代码是一个clearfix实现,用于在页面上重新浮动元素。

回答by Moin Zaman

That adds a space character to clear floats. Google clearfix and you will see similar things.

这添加了一个空格字符来清除浮动。谷歌clearfix,你会看到类似的东西。

Reference: The content property may contain: text strings, URI of external resources (an image for example), and ASCII code special characters. For high quality typesetting it is recommended using ISO 10646 characters and encoding them in their HEX representation.

参考:内容属性可能包含:文本字符串、外部资源的 URI(例如图像)和 ASCII 代码特殊字符。对于高质量的排版,建议使用 ISO 10646 字符并以十六进制表示对其进行编码。

A single space HEX is 20, so you would use \0020

单个空格 HEX 是 20,因此您将使用 \0020