css - 方括号中的 "i"在 CSS 选择器中有什么作用?

标签 css google-chrome css-selectors

<分区>

我刚刚在 chrome 开发者控制台中发现这个选择器作为“用户代理样式表”:

input[type="radio" i], input[type="checkbox" i] { ... }

“我”是做什么的?我以前从未在选择器中见过这种结构。

谢谢。

最佳答案

这是 Case-Sensitive Attribute Selector已在 Selectors Level 4 工作草案中引入:

E[foo="bar" i]
An E element whose foo attribute value is exactly equal to any (ASCII-range) case-permutation of bar.

6.3. Case-sensitivity

By default case-sensitivity of attribute names and values in selectors depends on the document language. To match attribute values case-insensitively regardless of document language rules, the attribute selector may include the identifier i before the closing bracket (]). When this flag is present, UAs must match the attribute's value case-insensitively within the ASCII range.

Example 13

The following rule will style the frame attribute when it has a value of hsides, whether that value is represented as hsides, HSIDES, hSides, etc. even in an XML environment where attribute values are case-sensitive.

[frame=hsides i] { border-style: solid none; }

值得注意的是,目前浏览器对此的支持即使不是不存在也将非常差。确实使用此选择器的现有 CSS 实现可能正在使用外部 JavaScript 库来模仿选择器级别 4 的定义。

关于css - 方括号中的 "i"在 CSS 选择器中有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32396210/

相关文章:

jquery - 加载时的 css3 过渡

javascript - 用于更改 Chrome 设置的 Chrome 扩展程序

javascript - Protractor/Js - 无法获得准确的表格行数和列数

javascript - 如果存在我的类(class)以外的类(class)

javascript - jQuery @变量?

html - CSS位置固定中心兄弟

html - 当元素不响应 CSS 设计时。问题通常来自框架工作吗?(在这种情况下是 Bootstrap )

html - CSS 样式冲突预防和命名空间技术

google-chrome - NPAPI 插件在 Google Chrome 中不起作用

javascript - Chrome 扩展 : writing content into a dynamic iframe created in a sandboxed environment