简体   繁体   English

CSS中的独立属性选择器

[英]Standalone attribute selector in CSS

I am using standalone attribute selectors since I discovered AMCSS . 自发现AMCSS以来,我一直在使用独立的属性选择器。 Recently I switched to cssnext from Compass and discovered that syntax highlighting seems to be broken in Atom and some other places/apps that I tested. 最近,我从Compass切换到cssnext ,发现在Atom和我测试的其他一些地方/应用程序中语法高亮显示似乎已损坏。

/* So this thing will be highlighted properly */

h1[foo] { font-weight: bold; }

/* and this thing not */

[foo] { font-weight: bold; }

The weird thing is that I couldn't find any examples of standalone attribute selector in specifications, but they work perfectly. 奇怪的是,我在规范中找不到独立的属性选择器的任何示例,但是它们运行良好。 All the examples uses combined selectors like h1[foo] . 所有示例都使用组合的选择器,例如h1[foo]

TL;DR TL; DR

Is [foo] the same as *[foo] and is safe to use, or is it just a coincidence that it works? [foo]是否与*[foo]相同并且可以安全使用,或者它只是巧合而已?

使用h1[foo][foo]h1.bar vs .bar相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM