css - CSS 选择器中的特殊字符

标签 css special-characters

我在 semantic UI 中找到了这个 CSS 定义.他们广泛使用这种风格。

.ui.\32.buttons > .button,
.ui.two.buttons > .button {
  width: 50%;
}

我可以看到他们想要完成的事情。 他们希望 CSS 定义阅读

.ui.2.buttons > .button,

必须是ASCII码。代码\32 将是一个空格。代码\3 将是“文本的开始”。

你能解释一下这里发生了什么吗?为什么ascii不转换成空格? 为什么 W3C CSS validator接受这个 CSS 没有错误?

最佳答案

\32十六进制 32,转换为十进制数 50,这确实是字符 2\31 将是 1

我从 W3C 规范中找到了这句话:

In CSS2, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [A-Za-z0-9] and ISO 10646 characters 161 and higher, plus the hyphen (-); they cannot start with a hyphen or a digit. They can also contain escaped characters and any ISO 10646 character as a numeric code (see next item). For instance, the identifier “B&W?” may be written as “B\&W\?” or “B\26 W\3F”.

我在 this arcticle 中找到了引用这把它放在上下文中,但它归结为这样一个事实,即虽然通常类名不能以数字开头,但当数字作为转义字符或(在本例中)输入时是允许的 ISO 10646 numeric code对于一个 Angular 色。

关于css - CSS 选择器中的特殊字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30692490/

相关文章:

CSS Sibling 的 child 选择器

url - 亚马逊 S3 : Access Denied for URL using symbols

objective-c - NSString 长度 - 特殊字符

css - 列表项的 ionic 响应式列

html - 添加内容时防止网格元素扩展

java - Java 标准输出中的克罗地亚语字符

php - php mysql 中不显示变音符号和特殊字符

php - 如何用PHP解析特殊字符到MySQL?

javascript - 如何使用 Canvas 创建动画形状的无限循环?

html - 在 Aurelia 中将 class.bind 与 HTML 元素中的 native 类结合起来